forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IssueTest.java
63 lines (58 loc) · 2.46 KB
/
IssueTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package test.listeners.github1602;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.List;
import org.testng.TestNG;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.collections.Lists;
import org.testng.xml.XmlSuite;
import test.SimpleBaseTest;
public class IssueTest extends SimpleBaseTest {
@Test(dataProvider = "dp")
public void testListenerInvocation(
Class<?> clazz, XmlSuite.FailurePolicy policy, List<String> expected) {
TestNG tng = create(clazz);
ListenerForIssue1602 listener = new ListenerForIssue1602();
tng.setConfigFailurePolicy(policy);
tng.addListener(listener);
tng.run();
assertThat(listener.getLogs()).containsExactlyElementsOf(expected);
}
@DataProvider(name = "dp")
public Object[][] getData() {
List<String> passList =
Arrays.asList(
"BeforeInvocation_beforeMethod_STARTED",
"AfterInvocation_beforeMethod_SUCCESS",
"BeforeInvocation_testMethod_STARTED",
"AfterInvocation_testMethod_SUCCESS",
"BeforeInvocation_afterMethod_STARTED",
"AfterInvocation_afterMethod_SUCCESS");
List<String> baseList =
Arrays.asList(
"BeforeInvocation_beforeMethod_STARTED",
"AfterInvocation_beforeMethod_FAILURE",
"BeforeInvocation_testMethod_STARTED",
"AfterInvocation_testMethod_SUCCESS",
"BeforeInvocation_afterMethod_STARTED");
List<String> commonSkipList =
Arrays.asList(
"BeforeInvocation_beforeMethod_STARTED",
"AfterInvocation_beforeMethod_FAILURE",
"BeforeInvocation_testMethod_SKIP",
"AfterInvocation_testMethod_SKIP",
"BeforeInvocation_afterMethod_STARTED",
"AfterInvocation_afterMethod_SKIP");
List<String> skipList = Lists.newArrayList(baseList);
skipList.add("AfterInvocation_afterMethod_SKIP");
List<String> failList = Lists.newArrayList(baseList);
failList.add("AfterInvocation_afterMethod_FAILURE");
return new Object[][] {
{TestClassWithPassingConfigsSample.class, XmlSuite.FailurePolicy.SKIP, passList},
{TestClassWithFailingConfigsSample.class, XmlSuite.FailurePolicy.SKIP, commonSkipList},
{TestClassWithPassingConfigsSample.class, XmlSuite.FailurePolicy.CONTINUE, passList},
{TestClassWithFailingConfigsSample.class, XmlSuite.FailurePolicy.CONTINUE, failList}
};
}
}