Reputation: 31
I am running TestCases programatically like,
TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng=new TestNG();
testng.setTestClasses(new Class[] { UserGroupTest.class });
testng.addListener(tla);
testng.run();
I have kept 8 test cases inside UserGroupTest.class
Is it possible to add testcase by testCase instead of adding whole class file?? Because I want to run testcases under condition basis. How to do tat?
Upvotes: 0
Views: 136
Reputation: 15608
If you only want to run certain methods from these classes, you have a few options:
Create a testng.xml (in-memory is probably the easiest since you are using the API) that will mimic the following XML:
<classes>
<class name="test.methods.SampleMethod1">
<methods>
<include name="shouldRun1" />
<include name="shouldRun2" />
Upvotes: 1