0

I have some integration tests in my project under src/test-integration/java.
I have no problem in running integration tests. But how do i run a single integration test through Terminal?

When i use mvn integration-test -Darg1=data1 it runs all the integration tests.

I tried using mvn integration-test -Dagr1=data1 -Dtest=IntegrationTestClass1 but it did not work

Any solutions?

I am using maven-surefire-plugin-2.9 and maven-failsafe-plugin-2.6

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
user2649233
  • 912
  • 4
  • 14
  • 28
  • What's the error? You sure you use proper package `IntegrationTestClass1for ` (the issue is that you could encounter problems with classes in the default package). – rlegendi Nov 12 '13 at 09:25
  • @rlegendi there is No error, it just runs all the integration tests instead of one test(IntegrationTestClass1). yes i have used the proper package. – user2649233 Nov 12 '13 at 11:33
  • i have also tried [http://stackoverflow.com/questions/894737/how-to-run-individual-test-in-the-integration-test-target-in-maven] but did not work out – user2649233 Nov 12 '13 at 11:33
  • Show us your failsafe configuration, because `src/test-integration/java` is not default location. Surefire is for unit tests, failsafe for integration tests. – MariuszS Nov 12 '13 at 12:10
  • I cant see in your pom `src/test-integration/java`? It is incomplete? – MariuszS Nov 14 '13 at 14:05

2 Answers2

0

Read this artice: Running a Single Test

Proper way to execute single integration test is to use property it.test

mvn -Dagr1=data1 -Dit.test=IntegrationTestClass1 verify

If this is not working then publish your pom.xml, because src/test-integration/java is not standard location for integrations test. Standard location for all tests by conventions is src/test/java. All integration test by default should have suffix IT. This is default failsafe configuration for integration tests.

MariuszS
  • 30,646
  • 12
  • 114
  • 155
  • I run my integration tests as `mvn integration-test -Darg=data -Pit` i have also tried the above method but it runs all the tests – user2649233 Nov 12 '13 at 12:02
-1

Below is my pom.xml, i can not chare my full pom because of some restrictions but this is the gist of it

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.8.1</version>
                </dependency>
            </dependencies>
            <configuration>
                <skipTests>false</skipTests>
                <failIfNoTests>false</failIfNoTests>
                <includes>
                    <include>**/*.class</include>
                </includes>
                <excludedGroups>com.IntegrationTest</excludedGroups>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.6</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.8.1</version>
                </dependency>
            </dependencies>
            <configuration>
                <reuseForks>true</reuseForks>
                <groups>com.IntegrationTest</groups>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                    <configuration>
                        <skipITs>false</skipITs>
                        <skipTests>false</skipTests>
                        <includes>
                            <include>**/*.class</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
user2649233
  • 912
  • 4
  • 14
  • 28