views:

49

answers:

3

We use several testing classes within one test folder. When I run mvn test, all tests are run and I can see the output in the shell. But the resulting testng-results.xml only has the results of the last class which was tested in it. This isn't too bad for me, but our hudson server only displays these last results and only marks a build as failed if one test within that last class failed.

How can I use TestNG with tests split over several classes which will be aggregated into on results-xml?

[update] Just found this question, but also no answer. [/update]

A: 

Does the console output tells you that all tests are run?

Peter Schuetze
Yes, it does. I get an output like "Tests run: 17, Failures: 0, ...\n\n Results :\n\n Tests run: 46, ..." The 17 are from the class which was run as last one, the 46 is the total.
DaDaDom
A: 

I'm not quite sure what's going on with Hudson but have you tried creating a testng.xml file and telling Surefire to use that testng.xml file instead of just discovering all the Java files that match *Test*java?

(just a shot in the dark)

This is how you do it:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <suiteXmlFiles>
        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
      </suiteXmlFiles>
    </configuration>
  </plugin>
Cedric Beust
Thanks, I'll try to do that and try to force separate output files/different suites for the tests.
DaDaDom
A: 

execute separate test classses in separate tags in one testNg file and use maven-surefire 2.5 plugin

Pushpinder Rattan