-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Github2560Test.java
47 lines (39 loc) · 2.15 KB
/
Github2560Test.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
package test.factory.github2560;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.testng.Assert;
import org.testng.TestNG;
import org.testng.annotations.Test;
import test.SimpleBaseTest;
public class Github2560Test extends SimpleBaseTest {
@Test
public void staticFactory() {
TestNG testng = create(FactoryTest.class);
testng.setDefaultSuiteName("Static @Factory tests");
InvokedMethodListener invokedMethodListener = new InvokedMethodListener();
testng.addListener(invokedMethodListener);
testng.run();
ImmutableMap<Integer, ImmutableList<String>> expected = ImmutableMap.of(
0, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass"),
1, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass"),
2, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass")
);
Assert.assertEquals(invokedMethodListener.capturedBeforeInvocations, expected, "beforeInvocation");
Assert.assertEquals(invokedMethodListener.capturedAfterInvocations, expected, "afterInvocation");
}
@Test
public void constructorFactory() {
TestNG testng = create(ConstructorTest.class);
testng.setDefaultSuiteName("Constructor @Factory tests");
InvokedMethodListener invokedMethodListener = new InvokedMethodListener();
testng.addListener(invokedMethodListener);
testng.run();
ImmutableMap<Integer, ImmutableList<String>> expected = ImmutableMap.of(
0, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass"),
1, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass"),
2, ImmutableList.of("beforeClass", "beforeMethod", "test", "afterMethod", "afterClass")
);
Assert.assertEquals(invokedMethodListener.capturedBeforeInvocations, expected, "beforeInvocation");
Assert.assertEquals(invokedMethodListener.capturedAfterInvocations, expected, "afterInvocation");
}
}