Annotation Type AnalyzeClasses


  • @Testable
    @Target(TYPE)
    @Retention(RUNTIME)
    @PublicAPI(usage=ACCESS)
    public @interface AnalyzeClasses
    Specifies which packages/locations should be scanned and tested when running a JUnit 5 test.

    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:
    ClassFileImporter
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      CacheMode cacheMode
      Controls, if JavaClasses should be cached by location, to be reused between several test classes, or just within the same class.
      java.lang.Class<? extends com.tngtech.archunit.core.importer.ImportOption>[] importOptions
      Allows to filter the class import.
      java.lang.Class<? extends LocationProvider>[] locations  
      java.lang.String[] packages  
      java.lang.Class<?>[] packagesOf  
    • Element Detail

      • packages

        java.lang.String[] packages
        Returns:
        Packages to look for within the classpath / modulepath
        Default:
        {}
      • packagesOf

        java.lang.Class<?>[] packagesOf
        Returns:
        Classes that specify packages to look for within the classpath / modulepath
        Default:
        {}
      • locations

        java.lang.Class<? extends LocationProvider>[] locations
        Returns:
        Implementations of LocationProvider. Allows to completely customize the sources, where classes are imported from.
        Default:
        {}
      • importOptions

        java.lang.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:
        com.tngtech.archunit.junit.CacheMode.FOREVER