Chetan
Chetan

Reputation: 1537

Running JUnit test suite using Maven

I have written a JUnit test suite for running multiple test cases.

Now I want to run my test suite class (AllTest.java) at once so that all tests are triggered, carried and managed by one class. I know maven-failsafe-plugin is available, but is there any other easier way to invoke a JUnit test suite from Maven?

I dont want to use another plugin for this.

This is my current maven-failsafe-plugin configuration:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.9</version>
  <configuration>
    <includes>
      <include>**/AllTests.java</include>
    </includes>
  </configuration>
  <executions>
    <execution>
      <id>integration-test</id>
      <goals>
        <goal>integration-test</goal>
      </goals>
    </execution>
    <execution>
      <id>verify</id>
      <goals>
        <goal>verify</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Upvotes: 13

Views: 24076

Answers (2)

artbristol
artbristol

Reputation: 32397

You can run it with -Dit.test=[package].AllTest (-Dtest with surefire), or configure the included tests in the pom:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.1</version>
    <configuration>
      <includes>
        <include>AllTest.java</include>
      </includes>
    </configuration>
  </plugin>

Upvotes: 15

swapyonubuntu
swapyonubuntu

Reputation: 2100

You can run test suite using following maven command:

 mvn test -Dtest=x.y.z.MyTestSuite

Note : x.y.z is the package name.

Upvotes: 3

Related Questions