TNG / ArchUnit

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

make tests included via `ArchTests` report outer class as test location #1279

Closed codecholeric closed 3 months ago

codecholeric commented 3 months ago

So far, if we include rules from other test classes, e.g.

@AnalyzeClasses(..)
class ExampleTest {
  @ArchTest
  static final ArchTests nested = ArchTests.in(Other.class);
}

then the included class (Other.class in this case) will be used as test location. This can cause confusion, because by this if Other.class is included in two separate test classes, analyzing different locations via @AnalyzeClasses, the results will be reported for the same test class Other.class. We now report the outermost class that started the test (the one with `@AnalyzeClasses) as the test location for both JUnit 4 and JUnit 5. To make it easy to understand through which path a rule is included in more complex scenarios, we extend the display name to include the path of nested classes.

Resolves: #452