We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Note: only the latest version is supported 7.4.0
7.4.0
@AfterGroups configuration method should wait for all tests (including the retried tests) to finish.
@AfterGroups
@AfterGroups configuration method runs before failed test retries are triggered.
Please, share the test case (as small as possible) which shows the issue
import static org.testng.Assert.assertTrue; 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 SampleTestClassWithGroupConfigs { public static final List<String> logs = new ArrayList<>(); @BeforeGroups("p1") public void beforeGroups() { logs.add("beforeGroups"); } @Test(groups = "p1", retryAnalyzer = RerunAnalyzer.class) public void testMethod() { logs.add("testMethod"); RerunAnalyzer.secondTestRetryCount++; assertTrue(RerunAnalyzer.secondTestRetryCount > RerunAnalyzer.maxRetryCount); } @AfterGroups("p1") public void afterGroups() { logs.add("afterGroups"); } }
import org.testng.IRetryAnalyzer; import org.testng.ITestResult; public class RerunAnalyzer implements IRetryAnalyzer { public static final int maxRetryCount = 1; public static int secondTestRetryCount = 0; private int retryCount = 0; @Override public boolean retry(ITestResult iTestResult) { if (retryCount < maxRetryCount) { retryCount++; return true; } return false; } }
import static org.testng.Assert.assertEquals; import java.util.Arrays; import java.util.Collections; import java.util.List; import org.testng.TestNG; import org.testng.annotations.Test; import org.testng.xml.XmlClass; import org.testng.xml.XmlGroups; import org.testng.xml.XmlRun; import org.testng.xml.XmlSuite; import org.testng.xml.XmlTest; public class IssueTest { @Test public void testRetriedTestsWithGroupConfigs() { XmlSuite xmlSuite = new XmlSuite(); xmlSuite.setName("groups_suite"); xmlSuite.setVerbose(2); XmlTest xmlTest = new XmlTest(xmlSuite); xmlTest.setName("groups_test"); XmlGroups xmlGroups = new XmlGroups(); XmlRun xmlRun = new XmlRun(); xmlRun.onInclude("p1"); xmlGroups.setRun(xmlRun); xmlTest.setGroups(xmlGroups); xmlTest.setClasses( Collections.singletonList( new XmlClass(SampleTestClassWithGroupConfigs.class) ) ); TestNG testng = new TestNG(); testng.setXmlSuites(Collections.singletonList(xmlSuite)); testng.run(); List<String> actual = SampleTestClassWithGroupConfigs.logs; List<String> expected = Arrays.asList("beforeGroups", "testMethod", "testMethod", "afterGroups"); assertEquals(actual, expected, actual + " didn't match elements in expected list" + expected); } }
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.
Reported from the TestNG dev forum
The text was updated successfully, but these errors were encountered:
Fix: AfterGroups config annotation does not consider retries for tests …
46804f6
…testng-team#2684
c221b49
Successfully merging a pull request may close this issue.
TestNG Version
Expected behaviour
@AfterGroups
configuration method should wait for all tests (including the retried tests) to finish.Actual behaviour
@AfterGroups
configuration method runs before failed test retries are triggered.Is the issue reproducible on runner?
Test case sample
Contribution guidelines
Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.
Reported from the TestNG dev forum
The text was updated successfully, but these errors were encountered: