|
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | 4 |
|
| 5 | +import java.util.ArrayList; |
| 6 | +import java.util.List; |
| 7 | +import org.testng.IMethodInstance; |
5 | 8 | import org.testng.ITestResult; |
6 | 9 | import org.testng.TestNG; |
7 | 10 | import org.testng.annotations.DataProvider; |
8 | 11 | import org.testng.annotations.Test; |
| 12 | +import org.testng.internal.MethodInstance; |
| 13 | +import org.testng.internal.WrappedTestNGMethod; |
9 | 14 | import org.testng.xml.XmlSuite; |
10 | 15 | import org.testng.xml.XmlSuite.FailurePolicy; |
11 | 16 | import test.SimpleBaseTest; |
12 | 17 | import test.aftergroups.issue165.TestclassSampleWithFailedMember; |
13 | 18 | import test.aftergroups.issue165.TestclassSampleWithSkippedMember; |
14 | 19 | import test.aftergroups.issue1880.LocalConfigListener; |
15 | 20 | import test.aftergroups.issue1880.TestClassSample; |
| 21 | +import test.aftergroups.samples.AfterGroupsSample; |
16 | 22 | import test.aftergroups.samples.MultipleGroupsSample; |
17 | 23 | import test.beforegroups.issue2359.ListenerAdapter; |
18 | 24 |
|
@@ -54,6 +60,26 @@ public void ensureAfterGroupsInvokedAfterAllTestsWhenMultipleGroupsDefined() { |
54 | 60 | t -> assertThat(t.getEndMillis()).isLessThanOrEqualTo(afterGroup.getStartMillis())); |
55 | 61 | } |
56 | 62 |
|
| 63 | + @Test |
| 64 | + public void ensureAfterGroupsInvokedWhenTestMethodIsWrappedWithWrappedTestNGMethod() { |
| 65 | + TestNG tng = new TestNG(); |
| 66 | + tng.setTestClasses(new Class[] {AfterGroupsSample.class}); |
| 67 | + |
| 68 | + tng.setMethodInterceptor( |
| 69 | + (methods, context) -> { |
| 70 | + List<IMethodInstance> result = new ArrayList<>(methods); |
| 71 | + result.add(new MethodInstance(new WrappedTestNGMethod(result.get(0).getMethod()))); |
| 72 | + return result; |
| 73 | + }); |
| 74 | + |
| 75 | + ListenerAdapter adapter = new ListenerAdapter(); |
| 76 | + tng.addListener(adapter); |
| 77 | + |
| 78 | + tng.run(); |
| 79 | + |
| 80 | + assertThat(adapter.getPassedConfiguration()).hasSize(1); |
| 81 | + } |
| 82 | + |
57 | 83 | private static void runTest( |
58 | 84 | Class<?> clazz, String groups, boolean shouldContinue, String expected) { |
59 | 85 | XmlSuite xmlsuite = createXmlSuite("sample_suite", "sample_test", clazz); |
|
0 commit comments