It seems that the API is not guiding very well with respect to this, because you’re not the first one wondering about this (this was also issue #1 on Github https://github.com/TNG/ArchUnit/issues/1).
To answer the question though, the Annotation @AnalyseClasses
has an extra attribute importOptions
, which takes arbitrary implementations of ImportOption
. There you can specify which Location
(basically the URI) to include.
Since excluding tests is rather common, this ImportOption
is already predefined (for Maven and Gradle < 4.0), so you can write
@AnalyzeClasses(..., importOptions = ImportOption.DoNotIncludeTests.class)
public class MyTest{ ... }
I don’t think, there is a generic solution for all setups (thus the freedom to just write your own ImportOption
to decide which locations to include). However, for standard Maven and Gradle setups, it should be working.