-
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.
Restore BeforeGroups|AfterGroups functionality back
Closes #2229 Ensure that BeforeGroups and AfterGroups config Methods always get invoked irrespective of whether Group level filtering being done by users.
- Loading branch information
1 parent
d9c6e45
commit 49dbdc9
Showing
6 changed files
with
181 additions
and
12 deletions.
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
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
52 changes: 52 additions & 0 deletions
52
testng-core/src/test/java/test/beforegroups/issue2229/AnotherTestClassSample.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,52 @@ | ||
package test.beforegroups.issue2229; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.testng.annotations.AfterGroups; | ||
import org.testng.annotations.BeforeGroups; | ||
import org.testng.annotations.Test; | ||
|
||
public class AnotherTestClassSample { | ||
|
||
public static List<String> logs = new ArrayList<>(); | ||
|
||
@BeforeGroups(groups = "testGroup1") | ||
public void beforeGroups1() { | ||
logs.add("beforeGroups1"); | ||
} | ||
|
||
@BeforeGroups(groups = "testGroup2") | ||
public void beforeGroups2() { | ||
logs.add("beforeGroups2"); | ||
} | ||
|
||
@AfterGroups(groups = "testGroup1") | ||
public void afterGroups1() { | ||
logs.add("afterGroups1"); | ||
} | ||
|
||
@AfterGroups(groups = "testGroup2") | ||
public void afterGroups2() { | ||
logs.add("afterGroups2"); | ||
} | ||
|
||
@Test(groups = "testGroup1") | ||
public void test1() { | ||
logs.add("test1_testGroup1"); | ||
} | ||
|
||
@Test(groups = "testGroup2") | ||
public void test2() { | ||
logs.add("test2_testGroup2"); | ||
} | ||
|
||
@Test(groups = "testGroup1") | ||
public void test3() { | ||
logs.add("test3_testGroup1"); | ||
} | ||
|
||
@Test(groups = "testGroup2") | ||
public void test4() { | ||
logs.add("test4_testGroup2"); | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
testng-core/src/test/java/test/beforegroups/issue2229/TestClassSample.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,93 @@ | ||
package test.beforegroups.issue2229; | ||
|
||
import static org.testng.Assert.assertFalse; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.AfterGroups; | ||
import org.testng.annotations.BeforeGroups; | ||
import org.testng.annotations.Test; | ||
|
||
public class TestClassSample { | ||
|
||
public static List<String> logs = new ArrayList<>(); | ||
|
||
boolean valueA = false; | ||
boolean valueB = false; | ||
|
||
@BeforeGroups(groups = "groupA") | ||
public void beforeGroupA() { | ||
logs.add("beforeGroupA"); | ||
valueA = true; | ||
} | ||
|
||
@BeforeGroups(groups = "groupB") | ||
public void beforeGroupB() { | ||
valueB = true; | ||
logs.add("beforeGroupB"); | ||
} | ||
|
||
@BeforeGroups(groups = "groupC") | ||
public void beforeGroupC() { | ||
logs.add("beforeGroupC No Test exist, should not run."); | ||
} | ||
|
||
@Test | ||
public void testA() { | ||
logs.add("TestA"); | ||
} | ||
|
||
@Test | ||
public void testB() { | ||
logs.add("TestB"); | ||
} | ||
|
||
@Test | ||
public void testC() { | ||
logs.add("TestC"); | ||
} | ||
|
||
@Test(groups = "groupA") | ||
public void testGroupA1() { | ||
logs.add("testGroupA1"); | ||
assertTrue(valueA, "BeforeGroupA was not executed"); | ||
} | ||
|
||
@Test(groups = "groupA") | ||
public void testGroupA2() { | ||
logs.add("testGroupA2"); | ||
assertTrue(valueA, "BeforeGroupA was not executed"); | ||
} | ||
|
||
@Test(groups = "groupA") | ||
public void testGroupA3() { | ||
logs.add("testGroupA3"); | ||
assertTrue(valueA, "BeforeGroupA was not executed"); | ||
} | ||
|
||
@Test(groups = "groupB") | ||
public void testGroupB() { | ||
logs.add("testGroupB"); | ||
assertTrue(valueB, "BeforeGroupB was not executed"); | ||
} | ||
|
||
@AfterGroups(groups = "groupA") | ||
public void afterGroupA() { | ||
logs.add("afterGroupA"); | ||
valueA = false; | ||
} | ||
|
||
@AfterGroups(groups = "groupB") | ||
public void afterGroupB() { | ||
logs.add("afterGroupB"); | ||
valueB = false; | ||
} | ||
|
||
@AfterClass | ||
public void afterClass() { | ||
assertFalse(valueA, "AfterGroupsA was not executed"); | ||
assertFalse(valueB, "AfterGroupsB was not executed"); | ||
} | ||
} |