Search code examples
javamavenjunitmaven-surefire-plugin

Is there a way to specify in Maven which JUnit tests run by package


I'm wondering if there is a way to specify in Maven which collection of JUnit tests run based on package names. An 'exclude' would be ideal, since I have fewer that I need not run than I have those that need to run.


Solution

  • Yes you can configure surefire plugin to include certain tests only

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
              <includes>
                <include>com/abc/*Test.java</include>
              </includes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    

    http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html