Source:
public boolean runMethodParallelAppium(List<String> test, String pack, int devicecount, String executionType) throws Exception { URL newUrl; List<URL> newUrls = new ArrayList<>(); Collections.addAll(items, pack.split("\\s*,\\s*")); int a = 0; Collection<URL> urls = ClasspathHelper.forPackage(items.get(a)); Iterator<URL> iter = urls.iterator(); URL url = null; while (iter.hasNext()) { url = iter.next(); if(url.toString().contains("test-classes")) { break; } } if(url == null){ new IllegalArgumentException("Please specify the package name containing tests"); } for (int i = 0; i < items.size(); i++) { newUrl = new URL(url.toString() + items.get(i).replaceAll("\\.", "/")); newUrls.add(newUrl); a++; } Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(newUrls) .setScanners(new MethodAnnotationsScanner())); Set<Method> resources = reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class); boolean hasFailure; String runnerLevel = System.getProperty("RUNNER_LEVEL") != null ? System.getProperty("RUNNER_LEVEL") : prop.getProperty("RUNNER_LEVEL"); if (executionType.equalsIgnoreCase("distribute")) { if (runnerLevel != null && runnerLevel.equalsIgnoreCase("class")) { constructXmlSuiteForDistribution(pack, test, createTestsMap(resources), devicecount); } else { constructXmlSuiteForDistributionMethods(pack, test, createTestsMap(resources), devicecount); } hasFailure = runMethodParallel(); } else { constructXmlSuiteForParallel(pack, test, createTestsMap(resources), devicecount, deviceAllocationManager.getDevices()); hasFailure = runMethodParallel(); } System.out.println("Finally complete"); figlet("Test Completed"); return hasFailure; }

Target:
public boolean runMethodParallelAppium(List<String> test, String pack, int devicecount, String executionType) throws Exception { URL newUrl; List<URL> newUrls = new ArrayList<>(); Collections.addAll(items, pack.split("\\s*,\\s*")); int a = 0; Collection<URL> urls = ClasspathHelper.forPackage(items.get(a)); Iterator<URL> iter = urls.iterator(); URL url = null; while (iter.hasNext()) { url = iter.next(); if(url.toString().contains("test-classes")) { break; } } if(url == null){ new RuntimeException("Please specify the package name containing tests"); } for (int i = 0; i < items.size(); i++) { newUrl = new URL(url.toString() + items.get(i).replaceAll("\\.", "/")); newUrls.add(newUrl); a++; } Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(newUrls) .setScanners(new MethodAnnotationsScanner())); Set<Method> resources = reflections.getMethodsAnnotatedWith(org.testng.annotations.Test.class); boolean hasFailure; String runnerLevel = System.getProperty("RUNNER_LEVEL") != null ? System.getProperty("RUNNER_LEVEL") : prop.getProperty("RUNNER_LEVEL"); if (executionType.equalsIgnoreCase("distribute")) { if (runnerLevel != null && runnerLevel.equalsIgnoreCase("class")) { constructXmlSuiteForDistribution(pack, test, createTestsMap(resources), devicecount); } else { constructXmlSuiteForDistributionMethods(pack, test, createTestsMap(resources), devicecount); } hasFailure = runMethodParallel(); } else { constructXmlSuiteForParallel(pack, test, createTestsMap(resources), devicecount, deviceAllocationManager.getDevices()); hasFailure = runMethodParallel(); } System.out.println("Finally complete"); figlet("Test Completed"); return hasFailure; }