Disclaimer: I am in no way an expert, this whole project was just a playground for me while I was waiting on onboarding nonsense.
You can run all the passing tests via gradle clean check
.
Some tests will not run for this task:
- Tests which are intended to fail are exlcluded by JUnit Tags - you can run these using
gradle clean alltests
, - The
pitest
tests are disabled by default, you can enable them by uncommenting the following line inbuild.gradle
://check.dependsOn 'pitest'
You'll need a valid docker environment to run the testcontainers
tests.
I'd recommend colima
if you're on a mac.
You may also need to run this to make your colima setup accessible:
sudo ln -s $HOME/.colima/docker.sock /var/run/docker.sock
Latest and greatest Java testing with lots of nifty features.
e.g.
@Nested
- divide big test classes up to give more structure,@ParameterizedTest
- reduce duplicated test setup,@DisplayName
- handy to make test output more readable,@Tag
- nice way of classifying tests, you can plug this into your build tool to run categories of tests (or avoid running them).
Used throughout, but particularly the junit
package.
Standard mocking library for easy test doubles.
See the mocking
package.
More fluid assertions.
Used throughout, but particularly the assertj
package.
Making it easier to test async code.
See the async
package.
Mocking for network calls (also a good way to test things like json deserialisation that lives in annotations).
See the wiremock
package.
BDD testing, allows you to write executable spec which is readable for non-techies.
See the features
dir for the feature files and the bdd
package for the step definitions and test runner.
In-memory DB which you can plug into your ORM to avoid needing a real one.
See the db
package.
Containers for your dependencies so you can run real services in your integration tests.
See the testcontainers
package and also the db
package.
Code coverage stats and enforcing - fails the build if coverage is too low.
The generated reports will live here after you run gradle clean build
:
See also some relevant config in build.gradle
.
Mutation testing to get more confidence on your coverage.
The generated report will live here after you run gradle clean build
.
See the pitest
package and some relevant config in build.gradle
.