Skip to content

Add ability to execute a subset of rules from the via system properties #641

@bobtiernay-okta

Description

@bobtiernay-okta

When developing large suite of ArchUnit rules, one common pattern is using multiple ArchRules / ArchTests in a single test class file:

 @AnalyzeClasses(..)
   class MyArchitectureTest {
       // includes all @ArchTest members from MyArchRuleSuite1
       @ArchTest
       static final ArchTests includedRules1 = ArchTests.in(MyArchRuleSuite1.class);
  
       // includes all @ArchTest members from MyArchRuleSuite2
       @ArchTest
       static final ArchTests includedRules2 = ArchTests.in(MyArchRuleSuite2.class);
}

However, each included ArchTests may run very slowly and it appears as though it is not possible to only run a subset of these tests from the command line. It would be great if new system properties were exposed that allowed JUnit 4 / 5 runners to only execute rules by pattern, in similar fashion to how JUnit does for test classes. Ideally this would work well with existing tooling for Maven (e.g. Surefire) and Gradle (e.g. test filtering).

One idea is exposing 2 new system properties:

  • archunit.tests.includePattern
  • archunit.tests.excludePattern

Which support wildcards. e.g.

  • my.org.MyArchitectureTest.includedRules1.rule2
  • *MyArchitectureTest.includedRules*.rule*

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions