Last active
August 29, 2015 14:18
-
-
Save OLibutzki/a4c0d3e7122e3a7828c4 to your computer and use it in GitHub Desktop.
TestNG parallelism issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tetsngparallel.ParallelTestClass@47d384ee: method1 running on thread 12, pool-1-thread-1 | |
tetsngparallel.ParallelTestClass@47d384ee: method2 running on thread 12, pool-1-thread-1 | |
tetsngparallel.ParallelTestClass@47d384ee: method3 running on thread 12, pool-1-thread-1 | |
tetsngparallel.ParallelTestClass@3930015a: method1 running on thread 13, pool-1-thread-2 | |
tetsngparallel.ParallelTestClass@3930015a: method2 running on thread 13, pool-1-thread-2 | |
tetsngparallel.ParallelTestClass@3930015a: method3 running on thread 13, pool-1-thread-2 | |
tetsngparallel.ParallelTestClass@629f0666: method1 running on thread 14, pool-1-thread-3 | |
tetsngparallel.ParallelTestClass@629f0666: method2 running on thread 14, pool-1-thread-3 | |
tetsngparallel.ParallelTestClass@629f0666: method3 running on thread 14, pool-1-thread-3 | |
tetsngparallel.ParallelTestClass@2d6a9952: method1 running on thread 15, pool-1-thread-4 | |
tetsngparallel.ParallelTestClass@2d6a9952: method2 running on thread 15, pool-1-thread-4 | |
tetsngparallel.ParallelTestClass@2d6a9952: method3 running on thread 15, pool-1-thread-4 | |
tetsngparallel.ParallelTestClass@1bc6a36e: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@1bc6a36e: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@1bc6a36e: method3 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@387c703b: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@387c703b: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@387c703b: method3 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@31b7dea0: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@31b7dea0: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@31b7dea0: method3 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@22a71081: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@22a71081: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@22a71081: method3 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@3ac42916: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@3ac42916: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@3ac42916: method3 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@1ff8b8f: method1 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@1ff8b8f: method2 running on thread 16, pool-1-thread-5 | |
tetsngparallel.ParallelTestClass@1ff8b8f: method3 running on thread 16, pool-1-thread-5 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tetsngparallel; | |
import org.testng.annotations.Test; | |
public class ParallelTestClass { | |
@Test | |
public void method1() { | |
printThreadInfo(); | |
sleep(); | |
} | |
//@Test(dependsOnMethods = "method1") | |
@Test | |
public void method2() { | |
printThreadInfo(); | |
sleep(); | |
} | |
//@Test(dependsOnMethods = "method2") | |
@Test | |
public void method3() { | |
printThreadInfo(); | |
sleep(); | |
} | |
private void sleep() { | |
try { | |
Thread.sleep(3000); | |
} catch (InterruptedException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
private void printThreadInfo() { | |
final Throwable t = new Throwable(); | |
final StackTraceElement methodCaller = t.getStackTrace()[1]; | |
System.out.println(toString() + ": " + methodCaller.getMethodName() + " running on thread " | |
+ Thread.currentThread().getId() + ", " | |
+ Thread.currentThread().getName()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tetsngparallel; | |
import org.testng.annotations.Factory; | |
public class ParellelTestFactory { | |
@Factory | |
public Object[] createInstances() { | |
Object[] result = new Object[10]; | |
for (int i = 0; i < 10; i++) { | |
result[i] = new ParallelTestClass(); | |
} | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<suite name="Tests" parallel="instances" group-by-instances="true"> | |
<test name="ParallelTestClass" group-by-instances="true"> | |
<classes> | |
<class name="tetsngparallel.ParellelTestFactory" /> | |
</classes> | |
</test> <!-- Test --> | |
</suite> <!-- Suite --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment