Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Last active August 15, 2019 11:41
Show Gist options
  • Save sabesansathananthan/1619e188696701bd153d25a1b8a47b65 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/1619e188696701bd153d25a1b8a47b65 to your computer and use it in GitHub Desktop.
Software parallelization custom implementation
public class TestThread impements Runnable{
public TestThread(String testGroupNam){
this.testGroupName=testGroupNam;
}
private String testGroupName;
@Override
public void run(){
TestNG testSuite = new TestNG(true);
TestBase c = constructGroup(testGroupName);
testSuite.setTestGroups(new Group[] {c.getGroup()});
testSuite.setDefaultSuiteName(c.getGroup().getSimpleName());
testSuite.setDefaultTestName(c.getGroup().getSimpleName());
testSuite.getReporters().add(new XMLReporter(c.getGroup().getSimpleName()));
testSuite.setOutputDirectory(System.getProperty("user.dir")+File.serparator+"target/testng-output");
testSuite.run();
}
private TestBase constructGroup(String groupName){
try{
Group<?>g=Group.forName(groupName);
Constructor<?>constructor=g.getConstructor();
return (TestBase) constructor.newInstance();
}catch (Exception e){
LoggerUtil.logERROR("Error in initializing the test class",e);
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment