views:

26

answers:

1

I want to lauch all my integration tests (group=inttest) so I write this xml config:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&gt;
<suite name="Service Integration Test" parallel="none">
  <test verbose="1" name="Service Integration Test">
    <groups>
      <run>
        <include name="inttest.*"/>
      </run>
    </groups>   
  </test>
</suite>

But when ran from intellij, no tests are ran. If I add a 'classes' section like this:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"&gt;
<suite name="Service Integration Test" parallel="none">
  <test verbose="1" name="Service Integration Test">
    <groups>
      <run>
        <include name="inttest.*"/>
      </run>
    </groups> 

   <classes>
     <class name="com.service.MyTestClass" />
   </classes>  
  </test>
</suite>

Then all test of the group 'inttest.*' contained in class com.service.MyTestClass are ran...

What's the problem ?

+2  A: 

As you correctly found out, you need to tell TestNG what classes it should be looking into in order to find the groups you specified.

You can also specify entire packages if you prefer.

As for why all test methods are run, I'll need to take a look at the class to figure out what's going on. Maybe you made all the test methods belong to a group "inttest" by specifying a @Test annotation at the class level?

Cedric Beust
Thanks Cedric. I've fixed my question about the 'all test methods are run'. When specifying the class, the test with the selected group are launched, as expected. For the package I should have make a mistake when trying to using this feature. It is working fine. I was expecting too much of the group feature: I was thinking that without any packages or classes, the whole codebase will be looked for group matching...
Guillaume