Add --test-command with real JaCoCo coverage; fix locale-dependent formatting - #3
Open
sgo wants to merge 1 commit into
Open
Add --test-command with real JaCoCo coverage; fix locale-dependent formatting#3sgo wants to merge 1 commit into
sgo wants to merge 1 commit into
Conversation
…ormatting crap4java's coverage step hardcoded `mvn ... test ...`, which requires JUnit-discoverable tests. Projects that run tests through a dedicated runner instead of `mvn test` (as SwarmForge's own engineering constitution requires for Java projects) got 0% coverage for everything and inflated CRAP scores, since no tests ever actually ran. - Add --test-command <cmd>, mirroring mutate4java's existing flag: runs <cmd> instead of `mvn test`. Coverage is still real: the JaCoCo runtime agent is resolved once per module (mvn dependency:copy, cached under target/) and attached to <cmd> via JAVA_TOOL_OPTIONS, so any JVM <cmd> launches contributes coverage; the report goal runs afterward. - CommandExecutor grows a runShell(cmd, dir, env) default method so existing lambda-based test doubles keep compiling unchanged. - Fix ReportFormatter and CliApplication's threshold message: %f formatting used the JVM default locale, rendering e.g. "85,0%" under non-English locales instead of "85.0%". Pinned to Locale.ROOT. - Update spec.md (§4.4, §7.2.1) and README to document the new flag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
I hit this while using crap4java through SwarmForge on a project whose Java
tests run through a dedicated test runner instead of
mvn test(SwarmForge'sown engineering constitution requires that convention for Java projects —
"avoid using Maven to run tests; build dedicated test runners and run those
instead"). Since crap4java's coverage step hardcoded
mvn ... test ...,Surefire found zero JUnit-discoverable tests, JaCoCo reported 0% coverage for
every method, and CRAP scores came out inflated for code that was actually
well tested.
Separately,
ReportFormatterand the threshold message usedString.formatwith the JVM default locale, so percentages rendered as
85,0%instead of85.0%under non-English locales.What this changes
--test-command <cmd>(mirrors the flagmutate4javaalready has):runs
<cmd>instead ofmvn testfor the module's tests. Coverage isstill real, not skipped: the JaCoCo runtime agent is resolved once per
module (
mvn dependency:copy, cached undertarget/jacoco-agent/) andattached to
<cmd>viaJAVA_TOOL_OPTIONS, so any JVM<cmd>launches —including a custom test runner — contributes coverage. The
reportgoalruns afterward against the accumulated
.execfile.CommandExecutorgets arunShell(cmd, dir, env)default method (fallsback to the existing no-env behavior), so this doesn't change the
signature existing lambda-based test doubles implement.
ReportFormatterandCliApplication's threshold message now format withLocale.ROOT.spec.md(new §4.4, §7.2.1) andREADME.mdto document the flag.Build, report generation, and agent resolution all stay Maven-based per
the existing spec — only the test-execution step itself becomes
overridable, which is why I didn't touch the "non-Maven execution"
non-goal in §2/§15.
All 65 existing + new tests pass (
mvn test).I'm not a maintainer here, just someone hitting this through SwarmForge, so
please push back freely if
JAVA_TOOL_OPTIONSinjection isn't the shapeyou'd want for this — happy to rework it.
🤖 Generated with Claude Code