Permalink
Browse files

Failing (and excluded) test to keep track of a dependsOnGroups bug.

  • Loading branch information...
1 parent 00e90c1 commit fb053618af7d984b537b27910468476dbce821ca @cbeust committed Mar 22, 2012
@@ -0,0 +1,28 @@
+package test.groupbug;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+import org.testng.collections.Lists;
+
+import test.BaseTest;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class GroupBugTest extends BaseTest {
+
+ static List<String> passed = Lists.newArrayList();
+
+ @Test(groups = "broken",
+ description = "Comment out dependsOnGroups in ITCaseOne will fix the ordering, that's the bug")
+ public void shouldOrderByClass() {
+ passed.clear();
+ addClass(ITCaseOne.class);
+ addClass(ITCaseTwo.class);
+ run();
+ List<String> expected = Arrays.asList(
+ "one1", "one2", "two1", "two2"
+ );
+ Assert.assertEquals(passed, expected);
+ }
+}
@@ -0,0 +1,34 @@
+package test.groupbug;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ITCaseOne {
+
+ @BeforeClass
+ public void beforeClass() {
+ System.out.printf("RUN %s.beforeClass()\n", getClass());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void afterClass() {
+ System.out.printf("RUN %s.afterClass()\n", getClass());
+ }
+
+ @Test(groups = "std-one")
+ public void one1() {
+ GroupBugTest.passed.add("one1");
+ System.out.printf("RUN %s.one1()\n", getClass());
+ }
+
+ /**
+ * Commenting out dependsOnGroups fixes the ordering, that's the bug.
+ */
+ @Test(groups = "logic-one", dependsOnGroups = "std-one")
+ public void one2() {
+ GroupBugTest.passed.add("one2");
+ System.out.printf("RUN %s.one2()\n", getClass());
+ }
+
+}
@@ -0,0 +1,31 @@
+package test.groupbug;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ITCaseTwo {
+
+ @BeforeClass
+ public void beforeClass() {
+ System.out.printf("RUN %s.beforeClass()\n", getClass());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void afterClass() {
+ System.out.printf("RUN %s.afterClass()\n", getClass());
+ }
+
+ @Test(groups = "std-two")
+ public void two1() {
+ GroupBugTest.passed.add("two1");
+ System.out.printf("RUN %s.two1()\n", getClass());
+ }
+
+ @Test(groups = "logic-two", dependsOnGroups = "std-two")
+ public void two2() {
+ GroupBugTest.passed.add("two2");
+ System.out.printf("RUN %s.two2()\n", getClass());
+ }
+
+}
@@ -111,6 +111,7 @@
<class name="test.bug90.Bug90Test" />
<class name="test.bug92.Bug92Test" />
<class name="test.ReturnValueTest" />
+ <class name="test.groupbug.GroupBugTest" />
</classes>
</test>

0 comments on commit fb05361

Please sign in to comment.