TNG / ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java
http://archunit.org
Apache License 2.0
3.19k stars 289 forks source link

support executing single `@ArchTest` members #1280

Closed codecholeric closed 5 months ago

codecholeric commented 6 months ago

Currently there is no convenient way to execute a single @ArchTest rule of a test running with JUnit 4 or 5 support. As a simple mitigation we now provide the possibility to filter a single test via archunit.properties / system property. This change allows to e.g. pass

-Darchunit.junit.testFilter=rule_field_one,rule_field_two

to a test run, which will then filter the tests and only run the @Archtest fields or methods with the given name(s).

For now we don't support any wildcards or narrowing the match down by surrounding class name to see if this feature is even missed by users. Basic filtering for classes or packages should already be supported by the respective test launcher (i.e. both JUnit 4 and 5 support should respect filter requests for classes or packages already).

Issue: #641

codecholeric commented 5 months ago

I noticed that this junit.testFilter does not allow us to distinguish @ArchTests defined as fields and @ArchTests defined as methods, which could have the same member name, but that's probably not needed in practice.

Yes, I was aware of that, but as you wrote, I doubt that will really be a problem in practice. If it is, we can still ponder about making this more powerful. But, let's see first if there are really requirements for this...