Repository navigation
Fail the build when tests don't run or assertions are off - #945
Merged
Merged
Conversation
A class named FooTests or FooSpec never ran, and an include that matched nothing passed with zero tests.
Without -ea a Kotlin assert() does nothing, so a broken assertEquals from TestUtils or a bare assert passed. The flag is on the test compile only, so the published jar is unchanged.
Surefire 3.6 runs JUnit 4 tests on the JUnit Platform and no longer publishes surefire-junit4, so the pin kept a 3.5.6 provider inside a 3.6.1 plugin. TestNG from reactive-streams-tck no longer hides the JUnit 4 tests: all 440 run without the pin, and failIfNoTests fails the build if a provider ever runs none.
Surefire only reads the failIfNoTests user property when the plugin config leaves the parameter unset, so the literal value ignored the flag its own error message suggests. Co-Authored-By: Claude <noreply@anthropic.com>
|
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
Agents working in graphql-java-tools keep repeating the same mistakes, and the repo should change so a change that looks right from one file is right for the whole repo. Two of those mistakes hide in the test setup. A test class that isn't named
*Testnever runs and the build still passes. And most of our assertions are Kotlinassert(), includingassertEqualsinTestUtils, which does nothing when the JVM runs without-ea.Description
FooTestsorFooSpecruns, and an include that matches nothing fails withNo tests were executed!instead of passing with zero tests. No helper or fixture class gets picked up, it's still 440 tests in 46 classesfailIfNoTestsis set as a property instead of in the plugin config, so the-DfailIfNoTests=falsethat surefire's error message suggests still turns the check off-Xassertions=always-enable, soassert()in the tests runs whatever the runner does with-ea. Test compile only, so the published jar is unchangedsurefire-junit4pin. Its comment said TestNG fromreactive-streams-tckmakes surefire run none of the JUnit 4 tests, which doesn't happen anymore. Surefire 3.6 runs JUnit 4 on the JUnit Platform and stopped publishingsurefire-junit4after 3.5.6, so the pin kept a 3.5.6 provider inside the 3.6.1 plugin. Without it all 440 still run, andfailIfNoTestscovers the case the pin was there forSurefire and IntelliJ both pass
-eaby default, so the assert part is cheap insurance more than a fix for something we hit. I didn't moveTestUtilsonto JUnit'sAssert, since about 100 bareassert()calls in the tests would still need the flag.No release note, nothing changes for library users.
Checklist
No new tests since it's build config. Each check was run against the mistake it's for, with
mvn -B -ntp clean verifyon JDK 25:ProbeMisnamedTestsclass with a failing test passes onagent-friendly(440 tests) and fails here (Tests run: 441, Failures: 1)**/*Tests.*,agent-friendlypasses with no tests run, this branch fails withNo tests were executed!assertEqualsand a broken bareassertinDeprecatedDirectiveTest, run with-DenableAssertions=false, both pass without the flag and both fail with itmvn clean verifypasses on JDK 17 and 25 with 440 tests, same asagent-friendly. Build time didn't move noticeably (~11s, single runs).