java - TestNG iterate over test data instead of test methods -
when using dataprovider multiple testng methods, every method run info sets in sequence. instead want iterate on info sets , execute methods on each iteration. not care if results show every single test method result or summary of runs per method.
i tried option
order-by-instances="true"
in suite.xml no success.
sample code:
public class testngtest { @dataprovider(name = "dp") public object[][] createdata(method m) { homecoming new object[][] { new object[] { "cedric" }, new object[] {"martina"}}; } @test(dataprovider = "dp") public void test1(string s) throws interruptedexception { system.out.println("test1 " + s); thread.sleep(1000); } @test(dataprovider = "dp") public void test2(string s) throws interruptedexception { system.out.println("test2 " + s); thread.sleep(1000); } }
actual result:
test1 cedric test1 martina test2 cedric test2 martina passed: test1("cedric") passed: test1("martina") passed: test2("cedric") passed: test2("martina")
wanted result:
test1 cedric test2 cedric test1 martina test2 martina passed: test1("cedric") passed: test2("cedric") passed: test1("martina") passed: test2("martina")
please seek next listener groupbyinstanceenabler. can set listener in listeners annotation in test class (or test base of operations class if have such) or simpler , improve solution set in meta-inf allow testng load using serviceloader (http://testng.org/doc/documentation-main.html#listeners-service-loader)
this allow rid of suite.xml , need maintain meta-inf , enabler on classpath. anytime run test loaded - not need configure ide, create suites run - load listener out-of-the-box.
import org.testng.isuite; import org.testng.isuitelistener; public class groupbyinstanceenabler implements isuitelistener { @override public void onstart(isuite suite) { suite.getxmlsuite().setgroupbyinstances(true); } @override public void onfinish(isuite suite) { } }
pawel
java testng
No comments:
Post a Comment