diff --git a/CHANGES.txt b/CHANGES.txt index 315b0ad025..35e4717b4c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ Current +Fixed: GITHUB-1574: Before/After methods are not running when groups "include" in suite (Krishnan Mahadevan) Fixed: GITHUB-217: exception in DataProvider doesn't fail test run (Krishnan Mahadevan) Fixed: GITHUB-987: Parameters threadCount and parallel doesn't work with maven (Krishnan Mahadevan) Fixed: GITHUB-1472: Optimize DynamicGraph.getUnfinishedNodes (Krishnan Mahadevan & Nathan Reynolds) diff --git a/src/main/java/org/testng/internal/XmlMethodSelector.java b/src/main/java/org/testng/internal/XmlMethodSelector.java index 2b9b80f979..7b083ebf9b 100644 --- a/src/main/java/org/testng/internal/XmlMethodSelector.java +++ b/src/main/java/org/testng/internal/XmlMethodSelector.java @@ -275,6 +275,9 @@ private static boolean isIncluded(Collection includedGroups, boolean noG } private static boolean isExcluded(Collection excludedGroups, String... groups) { + if (!excludedGroups.isEmpty() && groups.length == 0) { + return true; + } return isMemberOf(excludedGroups, groups); } diff --git a/src/test/java/test/groupinvocation/GroupSuiteTest.java b/src/test/java/test/groupinvocation/GroupSuiteTest.java index 551feaf4a7..2e854c630b 100644 --- a/src/test/java/test/groupinvocation/GroupSuiteTest.java +++ b/src/test/java/test/groupinvocation/GroupSuiteTest.java @@ -14,6 +14,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -123,7 +124,7 @@ private void runWithSuite(String[] withSuiteFiles, boolean groupsWithXml, List g(String... groups) { return Arrays.asList(groups); } diff --git a/src/test/java/test/groupinvocation/Issue1574TestclassSample.java b/src/test/java/test/groupinvocation/Issue1574TestclassSample.java new file mode 100644 index 0000000000..716d57a37d --- /dev/null +++ b/src/test/java/test/groupinvocation/Issue1574TestclassSample.java @@ -0,0 +1,43 @@ +package test.groupinvocation; + +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +public class Issue1574TestclassSample { + @BeforeSuite + public void setupSuite() { + } + + @BeforeTest + public void setUpTest() { + } + + @BeforeMethod + public void setUpMethod() { + } + + @AfterMethod + public void tearDownMethod() { + } + + @AfterTest + public void tearDownTest() { + } + + @AfterSuite(alwaysRun = true) + public void tearDownSuite() { + } + + @Test(groups = {"sometest"}) + public void someTest() { + } + + @Test(groups = {"anothertest"}) + public void anothertest() { + } +}