Class AffectedTestsExtension

java.lang.Object
io.affectedtests.gradle.AffectedTestsExtension

public abstract class AffectedTestsExtension extends Object
DSL extension for configuring the Affected Tests plugin.

Usage in build.gradle:


 affectedTests {
     baseRef = "origin/master"
     includeUncommitted = true
     runAllIfNoMatches = false
     strategies = ["naming", "usage", "impl", "transitive"]
     transitiveDepth = 2
     testSuffixes = ["Test", "IT", "ITTest", "IntegrationTest"]
     sourceDirs = ["src/main/java"]
     testDirs = ["src/test/java"]
     excludePaths = ["**/generated/**"]
     includeImplementationTests = true
     implementationNaming = ["Impl"]
 }
 
  • Constructor Details

    • AffectedTestsExtension

      public AffectedTestsExtension()
  • Method Details

    • getBaseRef

      public abstract org.gradle.api.provider.Property<String> getBaseRef()
      Git base ref to diff against. Default: "origin/master".
      Returns:
      the base ref property
    • getIncludeUncommitted

      public abstract org.gradle.api.provider.Property<Boolean> getIncludeUncommitted()
      Include uncommitted (unstaged) changes. Default: true.
      Returns:
      the include uncommitted property
    • getIncludeStaged

      public abstract org.gradle.api.provider.Property<Boolean> getIncludeStaged()
      Include staged changes. Default: true.
      Returns:
      the include staged property
    • getRunAllIfNoMatches

      public abstract org.gradle.api.provider.Property<Boolean> getRunAllIfNoMatches()
      Run full test suite if no affected tests are found. Default: false.
      Returns:
      the run-all-if-no-matches property
    • getRunAllOnNonJavaChange

      public abstract org.gradle.api.provider.Property<Boolean> getRunAllOnNonJavaChange()
      Force a full test run whenever the change set contains any file that cannot be resolved to a Java class under getSourceDirs() or getTestDirs() — for example application.yml, build.gradle, a Liquibase changelog, or a logback config. Files matching getExcludePaths() are treated as an explicit opt-out and do not trigger the escalation.

      Default: true — "run more, never run less".

      Returns:
      the run-all-on-non-java-change property
    • getStrategies

      public abstract org.gradle.api.provider.ListProperty<String> getStrategies()
      Strategies to use for test discovery. Valid values: "naming", "usage", "impl", "transitive". Default: all four.

      The transitive strategy additionally respects transitiveDepth.

      Returns:
      the strategies list property
    • getTransitiveDepth

      public abstract org.gradle.api.provider.Property<Integer> getTransitiveDepth()
      How many levels of transitive dependencies to follow when the transitive strategy is enabled. Default: 2. Range: 0–5.
      Returns:
      the transitive depth property
    • getTestSuffixes

      public abstract org.gradle.api.provider.ListProperty<String> getTestSuffixes()
      Test class suffixes used by the naming strategy. Default: ["Test", "IT", "ITTest", "IntegrationTest"].
      Returns:
      the test suffixes list property
    • getSourceDirs

      public abstract org.gradle.api.provider.ListProperty<String> getSourceDirs()
      Production source directories (relative to each module root). Default: ["src/main/java"].
      Returns:
      the source dirs list property
    • getTestDirs

      public abstract org.gradle.api.provider.ListProperty<String> getTestDirs()
      Test source directories (relative to each module root). Default: ["src/test/java"].
      Returns:
      the test dirs list property
    • getExcludePaths

      public abstract org.gradle.api.provider.ListProperty<String> getExcludePaths()
      Glob patterns for files to exclude from analysis. Default: ["&#42;&#42;/generated/&#42;&#42;"].
      Returns:
      the exclude paths list property
    • getIncludeImplementationTests

      public abstract org.gradle.api.provider.Property<Boolean> getIncludeImplementationTests()
      Include tests for implementations of changed interfaces/base classes. Default: true.
      Returns:
      the include implementation tests property
    • getImplementationNaming

      public abstract org.gradle.api.provider.ListProperty<String> getImplementationNaming()
      Implementation naming suffixes (e.g. "Impl" matches FooBarImpl for FooBar). Default: ["Impl"].
      Returns:
      the implementation naming list property