Search code examples
gradlearchunit

ArchUnit: How to get gradle to execute the tests?


I have a gradle project where I've added the archunit-junit5 dependency and written some test classes with @ArchTests. These get picked up by IntelliJ.

How do I get gradle to execute them?

I've found the com.societegenerale.commons:arch-unit-gradle-plugin but that seems to need configuration in the gradle file.

I just want gradle to pick up the tests I already have in the test/java directory.


Solution

  • Gradle should pick up @ArchTests with archunit-junit5 if you useJUnitPlatform().
    https://github.com/TNG/ArchUnit-Examples/tree/main/example-junit5 shows a quite minimal working example.