testng.xml trying to run all tests instead of only the included ones

1,786 views
Skip to first unread message

Fozzle

unread,
Sep 19, 2012, 11:25:55 AM9/19/12
to testng...@googlegroups.com
Hi,

I have set up testng.xml to look through a package that has only one TestNG test in it.  There are JUnit tests in the package and they are being picked up as well.  I am running in 'mixed' mode and using CLASSFILESET to run the JUnit tests.  I want to use XMLFILESET to run the TestNG tests so we can migrate gradually.

To try and get around this I've set up testng.xml to only include groups called "testng", of which 1 exists.  I was expecting it to look through the package, find all the JUnit tests, check if they were included or not and then skip them because they're not included.  Then run the 1 TestNG test.  However, it is still including them all (and falling over when trying to run them).

I hope that makes sense, sample code below.  Any help is much appreciated.

Foz

<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false" verbose="3">
 
  <listeners>
    <listener class-name="com.abc.xyz.SuiteListener" />
  </listeners>

  <groups>
    <run>
    <include name="testng" />
    </run>
  </groups>

  <test name="BaseTest">
    <packages>
    <package name="com.abc.xyz.*" />
    </packages>
  </test> <!-- Base Test -->
  
  
</suite> <!-- Suite -->

This simple test exists in the package.

public class TestNGSimpleTest {
@BeforeClass
public void setUp() {
// code that will be invoked when this test is instantiated
System.out.println("Test instantiated");
}

@Test(groups = { "testng" })
public void aFastTest() {
System.out.println("Fast test");
}

@Test(groups = { "slow" })
public void aSlowTest() {
System.out.println("Slow test");
}

}


niharika varshney

unread,
Sep 19, 2012, 1:55:40 PM9/19/12
to testng...@googlegroups.com
The groups have to mentioned inside the <test> and not outside it.
i.e.

<test name="BaseTest">
 <groups>
    <run>
    <include name="testng" />
    </run>
  </groups>
    <packages>
     <package name="com.abc.xyz.*" />
    </packages>
  </test> <!-- Base Test -->

This should work then as expected.

Regards,
Niharika



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/VTNahS5x7rwJ.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.

Message has been deleted

Fozzle

unread,
Sep 20, 2012, 3:51:25 AM9/20/12
to testng...@googlegroups.com
Hi  Niharika,

I tried putting the groups inside the <test> tags to begin with, that doesn't work either.

As per Sid's post, this works when I use classes but not packages.

Fiona


Fozzle

unread,
Sep 20, 2012, 3:58:59 AM9/20/12
to testng...@googlegroups.com
FYI Niharika,  here's an excerpt from the testng documentation;

Groups are specified in your testng.xml file and can be found either under the <test> or <suite> tag. Groups specified in the <suite> tag apply to all the <test> tags underneath. Note that groups are accumulative in these tags: if you specify group "a" in <suite> and "b" in <test>, then both "a" and "b" will be included. 


Fozzle

unread,
Sep 21, 2012, 8:34:26 AM9/21/12
to testng...@googlegroups.com
Anyone got a solution for this?


Fozzle

unread,
Sep 24, 2012, 5:28:48 AM9/24/12
to testng...@googlegroups.com
Anyone got any suggestions for this issue?
Reply all
Reply to author
Forward
0 new messages