Package com.tngtech.archunit.junit
Annotation Interface AnalyzeClasses
Specifies which packages/locations should be scanned and tested when running a test with the
To ignore certain classes (e.g. classes in test scope) see
When checking rules, it is important to remember that all relevant information/classes need to be imported for the rules to work. For example, if class A accesses class B and class B extends class C, but class B is not imported, then a rule checking for no accesses to classes assignable to C will not fail, since ArchUnit does not know about the details of class B, but only simple information like the fully qualified name. For information how to configure the import and resolution behavior of missing classes, compare
ArchUnitRunner.
To ignore certain classes (e.g. classes in test scope) see
importOptions(), in particular ImportOption.DoNotIncludeTests and
ImportOption.DoNotIncludeJars.
When checking rules, it is important to remember that all relevant information/classes need to be imported for the rules to work. For example, if class A accesses class B and class B extends class C, but class B is not imported, then a rule checking for no accesses to classes assignable to C will not fail, since ArchUnit does not know about the details of class B, but only simple information like the fully qualified name. For information how to configure the import and resolution behavior of missing classes, compare
ClassFileImporter.- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionControls, ifJavaClassesshould be cached by location, to be reused between several test classes, or just within the same class.Class<? extends com.tngtech.archunit.core.importer.ImportOption>[]Allows to filter the class import.Class<? extends LocationProvider>[]String[]Class<?>[]boolean
-
Element Details
-
packages
String[] packages- Returns:
- Packages to look for within the classpath / modulepath
- Default:
{}
-
packagesOf
Class<?>[] packagesOf- Returns:
- Classes that specify packages to look for within the classpath / modulepath
- Default:
{}
-
locations
Class<? extends LocationProvider>[] locations- Returns:
- Implementations of
LocationProvider. Allows to completely customize the sources, where classes are imported from.
- Default:
{}
-
wholeClasspath
boolean wholeClasspath- Returns:
- Whether to import all classes on the classpath. Warning: Without any further filtering this can require a lot of resources.
- Default:
false
-
importOptions
Class<? extends com.tngtech.archunit.core.importer.ImportOption>[] importOptionsAllows to filter the class import. The supplied types will be instantiated and used to create theImportOptionspassed to theClassFileImporter. Considering caching, compare the notes onImportOption.- Returns:
- The types of
ImportOptionto use for the import
- Default:
{}
-
cacheMode
CacheMode cacheModeControls, ifJavaClassesshould be cached by location, to be reused between several test classes, or just within the same class.- Returns:
- The
CacheModeto use for this test class.
- Default:
FOREVER
-