Annotation Interface AnalyzeClasses


@Target(TYPE) @Retention(RUNTIME) public @interface AnalyzeClasses
Specifies which packages/locations should be scanned and tested when running a test with the 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:
  • 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>[] importOptions
      Allows to filter the class import. The supplied types will be instantiated and used to create the ImportOptions passed to the ClassFileImporter. Considering caching, compare the notes on ImportOption.
      Returns:
      The types of ImportOption to use for the import
      Default:
      {}
    • cacheMode

      CacheMode cacheMode
      Controls, if JavaClasses should be cached by location, to be reused between several test classes, or just within the same class.
      Returns:
      The CacheMode to use for this test class.
      Default:
      FOREVER