views:

946

answers:

1

Hello everyone,

We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.

What I want to do is run just one test in the integration-test. I tried doing :

mvn -Dtest=<my-test> integration-test

but that does not work. The -Dtest runs only the tests in the unit test goal, not the integration-test phase. I tried the -Dintegration-test= instead, and that was ignored.

Is there a way to do that ? Googling didn't really help :)

Thanks,

--- Jalpesh

+1  A: 

I'm not sure about JUnit, but for TestNG the strategy would be to define a suite XML file with only the one test, and then in your POM configure the surefire plugin to only run that. In your POM, you would have something like this (disclaimer, this is untested):

  <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <executions>
      <execution>
        <phase>integration-test</phase>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>single-test.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

To configure the suite file, see http://testng.org/doc/documentation-main.html

James Kingsbery
I agree with James. TestNG is suitable for that, but I think it's better to use TestNG groups:@Test(groups = { "slow_test" })Then in your TestNG suite:<suite name="My suite"><test name="Slow tests"><groups><run><include name="slow_test"/></run></groups></test></suite>Then you could always include/exclude particular groups
Pavel Rodionov