Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Last active August 15, 2019 10:42
Show Gist options
  • Save sabesansathananthan/8b45add87826fb915a20b6abc7c2ef86 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/8b45add87826fb915a20b6abc7c2ef86 to your computer and use it in GitHub Desktop.
Software parallelization custom implementation
public class TestNGParallelRunner{
public static void main(String[] args){
if(PARALLEL_ENABLE){
SeleniumGridManager seleniumGridManager = new SeleniumGridManager();
seleniumGridManager.startSeleniumGrid();
try{
List<String>testGroup=new TestNGXmlParser().getTestGroupsFromTestNGXml(TEST_SUITE);
ExecutorService executoService = Executor.newFixedThreadPool(THREAD_COUNT);
for(String testGroup : testGroups){
TestThread testThread = new TestThread(testGroup);
executorService.execute(testThread);
}
executorService.shutdown();
while (!executorService.isTerminated()){}
System.out.println("Finished all threads");
}catch (Exception e){
LoggerUtil.logERROR{"Error in executing the test suite",e}
}finally{
seleniumGridManager.stopSeleniumGrid();
}
}else{
LoggerUtil.logWARNING("Parallel mode is disabled. Please enable it");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment