Reputation: 1100
I see that I have a testNG group like
class TestXYZ {
@Test(groups = "group1")
public void test1() {
Assert.assertTrue(true);
}
@Test(groups = "group1")
public void test2() {
Assert.assertTrue(false);
}
}
Now if I want to run the whole group tests I can use
java -cp testjar.jar org.testng.TestNG -testjar testjar.jar -groups group1
(Assume that testjar.jar is a fat jar that has all testNG and test classes bundled together).
But I am not sure how to run test1 only from the group1 group. I tried out the -methods option, but realized that it's not for a method within a group, couldn't find any other solutions online.
Upvotes: 1
Views: 490
Reputation: 2149
There is other way to run tests using a combination of regular expression and xml
configuration file.
Say, you have four tests:
@test(groups={"test1"})
public void testMethodOne() {}
@test(groups={"test11"})
public void testMethodOneOne() {}
@test(groups={"test20"})
public void testMethodTwoZero() {}
@test(groups={"test21"})
public void testMethodTwoOne() {}
In the xml
configuration file, you can write something like below:
<run>
<include name="test1.*"/>
<exclude name="test2.*"/>
</run>
this .* is basically a wild card, all tests that have names starting with test1 will be executed while all tests that have names starting with test2 will not be.
Another example will be, if you use this string .*test.*
, you are basically searching for a test name that has this test
string in it, a few examples are:
This should provide more scalability than my first suggestion.
Upvotes: 1
Reputation: 2149
Can you please try this approach by assigning your tests into different groups? Say, smokeTest and functionTest groups.
class TestXYZ {
@Test(groups = "group1", "smokeTest")
public void test1() {
Assert.assertTrue(true);
}
@Test(groups = "group1", "functionTest")
public void test2() {
Assert.assertTrue(false);
}
}
Then you can
Upvotes: 1