-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1477 from juherr/issue-#565
Issue #565
- Loading branch information
Showing
6 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package test.issue565; | ||
|
||
import org.testng.Assert; | ||
import org.testng.ITestNGListener; | ||
import org.testng.TestListenerAdapter; | ||
import org.testng.TestNG; | ||
import org.testng.annotations.Test; | ||
import org.testng.xml.XmlSuite; | ||
import org.testng.xml.XmlSuite.ParallelMode; | ||
import org.testng.xml.XmlTest; | ||
import test.SimpleBaseTest; | ||
import test.issue565.deadlock.ClassInGroupB; | ||
import test.issue565.deadlock.GeneratedClassFactory; | ||
|
||
public class Issue565Test extends SimpleBaseTest { | ||
|
||
@Test | ||
public void ThereShouldNotBeDeadlockWhenGroupByInstanceAndGroupDependencyUsed() throws Exception { | ||
|
||
XmlSuite suite = createXmlSuite("Deadlock-Suite"); | ||
suite.setParallel(ParallelMode.CLASSES); | ||
suite.setThreadCount(5); | ||
suite.setVerbose(10); | ||
suite.setGroupByInstances(true); | ||
|
||
XmlTest test = createXmlTestWithPackages(suite, "Deadlock-Test", ClassInGroupB.class); | ||
|
||
// Prevent real deadlock | ||
suite.setTimeOut("1000"); | ||
test.setTimeOut(1_000); | ||
|
||
TestNG tng = create(suite); | ||
TestListenerAdapter tla = new TestListenerAdapter(); | ||
tng.addListener((ITestNGListener) tla); | ||
tng.run(); | ||
|
||
Assert.assertEquals(tla.getFailedTests().size(), 0); | ||
Assert.assertEquals(tla.getSkippedTests().size(), 0); | ||
Assert.assertEquals(tla.getPassedTests().size(), 2 + 4 * GeneratedClassFactory.SIZE); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package test.issue565.deadlock; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "B", dependsOnGroups = "A") | ||
public class ClassInGroupB { | ||
|
||
@Test | ||
public void groupB_1() { } | ||
|
||
@Test(dependsOnMethods = "groupB_1") | ||
public void groupB_2() { } | ||
} |
25 changes: 25 additions & 0 deletions
25
src/test/java/test/issue565/deadlock/GeneratedClassFactory.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package test.issue565.deadlock; | ||
|
||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Factory; | ||
|
||
public class GeneratedClassFactory { | ||
|
||
public static final int SIZE = 20; | ||
|
||
@DataProvider(name = "ids", parallel = true) | ||
public Object[][] ids() { | ||
Integer[][] params = new Integer[SIZE][1]; | ||
for (int id = 0; id < params.length; id++) { | ||
params[id] = new Integer[]{id}; | ||
} | ||
return params; | ||
} | ||
|
||
@Factory(dataProvider = "ids") | ||
public Object[] generate(int id) { | ||
return new Object[]{ | ||
new GeneratedClassInGroupA(id) | ||
}; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/test/java/test/issue565/deadlock/GeneratedClassInGroupA.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package test.issue565.deadlock; | ||
|
||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
public class GeneratedClassInGroupA { | ||
|
||
private final int id; | ||
|
||
public GeneratedClassInGroupA(int id) { | ||
this.id = id; | ||
} | ||
|
||
@BeforeClass(groups = "A") | ||
public void init() { } | ||
|
||
@Test(groups = "A") | ||
public void test1() { } | ||
|
||
@Test(groups = "A", dependsOnMethods = "test4") | ||
public void test2() { } | ||
|
||
@Test(groups = "A") | ||
public void test3() { } | ||
|
||
@Test(groups = "A", dependsOnMethods = "test3") | ||
public void test4() { } | ||
|
||
@Override | ||
public String toString() { | ||
return "GeneratedClassInGroupA{" + id + '}'; | ||
} | ||
} |
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