Maven: How to configure maven to run unit test and integration test separately

I have a question about maven.

I have Unit Tests that have a file name ending in * Test and integration test, whose file name ends in * IT.

My understanding is that surefire will run the unit test, and failafe will run the integration test.

When I run: mvn clean install

Both unit test and integration tests run.

When I run:

mvn check

Both of these tests also run.

In any case, I can configure maven to use only: unit tests when using: mvn clean install. And when I use mvn check, only integration tests run?

My POM build section is as follows:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>failsafe-maven-plugin</artifactId>
            <version>2.4.3-alpha-1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
</build>

Many thanks

+3
2

, , , TestNameIT.java , TestNameUT.java, includes .

+1

Unit-Integration- Systemtest Maven

GitHub, maven. , , , , - maven SO

.

GitHub: https://github.com/StefanHeimberg/maven3-unit_integration_systemtest-setup

  • Maven 3.3
  • Production Systemtest DB.
  • Mockito

Unit-

  • /.
  • . (Mockito)
  • src/test , test

-

  • /-
  • EE.
  • Arquillian Remote Managed Wildfly
  • Datasource TestCase arquillian war (* -ds.xml)
  • DB JPA DDL (hibernate.hbm2ddl.auto = create-drop)
  • Arquillian Deploymentments ,
  • Testdata @Test @Before... ( ...)

System-

  • Wildfly WAR/EAR.
  • *.cli
  • , (hibernate.hbm2ddl.auto = validate)
  • maven-flyway-plugin
  • Testdata, sql-maven-plugin
0

All Articles