Skip to content

Conversation

@Pankraz76
Copy link
Contributor

@Pankraz76 Pankraz76 commented Dec 2, 2025

Add org.junit.openrewrite.SanityCheck

enabler for:

related to:


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch 2 times, most recently from 2630106 to bc5d7ff Compare December 2, 2025 11:13
Pankraz76

This comment was marked as off-topic.

@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from bc5d7ff to cc25b56 Compare December 2, 2025 11:28
@Pankraz76
Copy link
Contributor Author

discovering the specialties took more than 2h to collect.

Of course junit worth every effort.

BUILD SUCCESSFUL in 3m 19s

making this fully reprod. is first premise:

image

@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch 2 times, most recently from df3ca59 to 7b1dced Compare December 3, 2025 19:25
@Pankraz76 Pankraz76 changed the title [rewrite] add junit5.CleanupAssertions [junit] add JupiterBestPractices Dec 3, 2025
@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from 7b1dced to 90e9799 Compare December 4, 2025 11:28
@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from 90e9799 to fd77fdf Compare December 4, 2025 11:48
@Pankraz76 Pankraz76 changed the title [junit] add JupiterBestPractices [rewrite] add JupiterBestPractices Dec 4, 2025
@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from fd77fdf to c0dc000 Compare December 4, 2025 12:08
@Pankraz76

This comment was marked as off-topic.

@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from c0dc000 to 2ef0570 Compare December 5, 2025 11:01
@Pankraz76 Pankraz76 changed the title [rewrite] add JupiterBestPractices [rewrite] add org.junit.openrewrite.SanityCheck Dec 5, 2025
@testlens-app
Copy link

testlens-app bot commented Dec 5, 2025

✅ All tests passed ✅

🏷️ Commit: 4c1138f
▶️ Tests: 53948 executed
⚪️ Checks: 18/18 completed


Learn more about TestLens at testlens.app.

@Pankraz76 Pankraz76 changed the title [rewrite] add org.junit.openrewrite.SanityCheck [rewrite] add org.junit.openrewrite.SanityCheck 🕊 Dec 5, 2025
@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from 5ead7f7 to b33ddf8 Compare December 5, 2025 13:16
tasks.check {
dependsOn(tasks.withType<Checkstyle>())
}
//tasks.check { // assuming spotless does the job already, checkstyle is first dedicated redundancy layer.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming spotless does the job already, considering checkstyle as first dedicated redundancy layer.

}

tasks.check {
dependsOn(archUnit)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

considering this hopefully so rare, running this only "once" in CI.

@Pankraz76 Pankraz76 force-pushed the fix-JUnit5BestPractices branch from b33ddf8 to a155d8b Compare December 5, 2025 13:43
@Pankraz76
Copy link
Contributor Author

Kindly asking, if this is any good? @sbrannen @marcphilipp

Assuming the junit rules could help to embrace some junit conventions and best practices.

Thanks to the community.

@marcphilipp
Copy link
Member

As indicated in #4708 (comment), we don't want to add another static analysis tool to our build because of the additional execution time (even if it's "just" on GitHub Actions) and maintenance burden in our build.

Regarding the code changes made by the two rules you added to the SanityCheck configuration, we don't think EqualsAvoidsNull is useful for us since we've adopted JSpecify and NullAway and TimeRules seems to have made a single change in test code.

@Pankraz76
Copy link
Contributor Author

yes of course. Its actually ment to be used as into. The dedicated junit rules make a lot of changes, meaning junit it not quite aligned with its own best practises and conventions.

Is this something to consider?

The diff there is quite easy to see whats the benefit is provided.

@marcphilipp
Copy link
Member

I'm not really surprised by this. Our tests have to cover edge cases outside of the best practices. Moreover, testing JUnit with JUnit comes with its own set of challenges, so we can't always follow "best practices". For example, when testing assertions, we don't want to relay on assertions but use try-catch blocks.

@Pankraz76
Copy link
Contributor Author

Pankraz76 commented Dec 13, 2025

this the classic one i´ve been doing wrong for 15 years, so seems junit too, which is nothing to be worried about its something everybody having issues with, everyone except computer:

  • org.openrewrite.java.testing.cleanup.AssertionsArgumentOrder
> Task :platform-tests:rewriteRun
Changes have been made to platform-tests/src/test/java/org/junit/platform/reporting/legacy/xml/LegacyXmlReportGeneratingListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.RemoveTestPrefix
Changes have been made to platform-tests/src/test/java/org/junit/platform/reporting/open/xml/OpenTestReportGeneratingListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/reporting/open/xml/JUnitContributorTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/DefaultLauncherTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.junit5.AssertThrowsOnLastStatement
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/LauncherFactoryTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.RemoveTestPrefix
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/StreamInterceptorTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.SimplifyTestThrows
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/HierarchicalOutputDirectoryCreatorTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/ExecutionListenerAdapterTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.RemoveTestPrefix
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/ListenerRegistryTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/core/InternalTestPlanTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/listeners/SummaryGenerationTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/listeners/discovery/LoggingLauncherDiscoveryListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/listeners/LoggingListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/launcher/listeners/session/CompositeLauncherSessionListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/commons/util/ReflectionUtilsWithGenericTypeHierarchiesTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/commons/util/DefaultClasspathScannerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.SimplifyTestThrows
Changes have been made to platform-tests/src/test/java/org/junit/platform/commons/annotation/TestableAnnotationTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.RemoveTestPrefix
Changes have been made to platform-tests/src/test/java/org/junit/platform/commons/function/TryTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/commons/support/ResourceInteroperabilityTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/DiscoveryIssueTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/ForkJoinDeadLockTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/support/hierarchical/SameThreadExecutionIntegrationTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.SimplifyTestThrows
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/support/discovery/EngineDiscoveryRequestResolverTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/support/descriptor/ClassSourceTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.SimplifyTestThrows
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/support/store/NamespaceTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/engine/TestTagTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.junit5.CleanupAssertions
            org.openrewrite.java.testing.cleanup.AssertionsArgumentOrder
Changes have been made to platform-tests/src/test/java/org/junit/platform/StackTracePruningTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.junit5.StaticImports
            org.openrewrite.java.UseStaticImport: {methodPattern=org.junit.jupiter.api.Assertions *(..)}
Changes have been made to platform-tests/src/test/java/org/junit/platform/console/output/TestFeedPrintingListenerTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.RemoveTestPrefix
        org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
Changes have been made to platform-tests/src/test/java/org/junit/platform/console/ConsoleLauncherIntegrationTests.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.cleanup.SimplifyTestThrows
Changes have been made to platform-tests/src/jmh/java/org/junit/jupiter/jmh/AssertionBenchmarks.java by:
    org.openrewrite.java.testing.junit.JupiterBestPractices
        org.openrewrite.java.testing.junit5.StaticImports
            org.openrewrite.java.UseStaticImport: {methodPattern=org.junit.jupiter.api.Assertions *(..)}
        org.openrewrite.java.testing.cleanup.AssertLiteralBooleanRemovedRecipe
Please review and commit the results.
Estimate time saved: 1h 50m

Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Pankraz76 pushed a commit to Pankraz76/junit5 that referenced this pull request Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants