I wrote my first ArchUnit test:
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.*;
// more non-static imports
@RunWith(ArchUnitRunner.class)
@AnalyzeClasses(packages = "my.domain.project")
public class PackageStructureTests {
@ArchTest public static final ArchRule NO_CYCLES = slices().matching("my.domain.project.(**)")
.namingSlices("package:$1").should().beFreeOfCycles();
}
The problem is that it also analyzes classes in tests, which don't follow that simple dependency constraint.
How do I limit the test to the "production" classes?
The project gets built with Maven, so the classes are in separate directories.
It is not sufficient to separate classes with names ending in "Tests" or something because there are many classes that aren't tests, but are only present on the test classpath.
DontIncludeTests
is deprecated (checked in ArchUnit 0.10.2). UseDoNotIncludeTests
(different spelling). – Demand