Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle: Add JUnit 5 support #418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rybak
Copy link
Contributor

@rybak rybak commented May 26, 2021

Gradle build script has been updated to support JUnit 5 APIs in tests. Logging and reporting of test results has been added.

  • Supports existing JUnit 4 tests as is, with no changes

  • JUnit 5 has nicer APIs for writing tests than JUnit 4

  • Stable API (5.0.0 was release four years ago)

  • Already supported by all major Java IDEs

  • With this PR merged, running:

    ./gradlew test
    

    will 1) produce human readable test results in the console and 2) produce nice HTML output in ./build/reports/tests/test/index.html

  • For vast majority of JUnit 4 tests, the migration is just replacing old imports with new ones. And for most of those it's just replacement of import static org.junit.Assert.* with import static org.junit.jupiter.api.Assertions.*.

rybak added 2 commits May 26, 2021 20:58
JUnit 5 supports better APIs that JUnit 4, making writing of tests
easier.  Use latest version of JUnit 5 available at the time of writing,
5.7.2 --- https://github.com/junit-team/junit5/releases

Note, that and JUnit 4 tests continue to work as before with no changes
required.
This is just to make running the test suite from the console a bit more
convenient.  With this testLogging, the output for current tests looks
like this:

    $ ./gradlew clean test
    [...]
    > Task :test
    -------------------------------------------------
    Testing result for chatty: SUCCESS
    94 tests run, 94 successes, 0 failures, 0 ignored
    -------------------------------------------------

    BUILD SUCCESSFUL in 18s
    6 actionable tasks: 6 executed
@rybak rybak changed the title Add JUnit 5 support Gradle: Add JUnit 5 support May 26, 2021
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.

None yet

1 participant