|
| 1 | +package test; |
| 2 | + |
| 3 | +import static org.assertj.core.api.Assertions.assertThat; |
| 4 | + |
| 5 | +import java.util.Arrays; |
| 6 | +import java.util.List; |
| 7 | +import org.testng.Assert; |
| 8 | +import org.testng.TestNG; |
| 9 | +import org.testng.annotations.Test; |
| 10 | +import test.configuration.issue2663.ConfigurationMethodPrioritySampleTest; |
| 11 | +import test.configuration.issue2663.ConfigurationMethodPriorityWithGroupDependencySampleTest; |
| 12 | +import test.configuration.issue2663.ConfigurationMethodPriorityWithMethodDependencySampleTest; |
| 13 | + |
| 14 | +public class ConfigurationMethodPriorityTest extends SimpleBaseTest { |
| 15 | + |
| 16 | + @Test(description = "GITHUB-2663") |
| 17 | + public void ensureThatPriorityWorksOnConfigurationMethods() { |
| 18 | + TestNG testng = create(ConfigurationMethodPrioritySampleTest.class); |
| 19 | + testng.run(); |
| 20 | + assertThat(testng.getStatus()).isEqualTo(0); |
| 21 | + List<String> expectedLogs = |
| 22 | + Arrays.asList( |
| 23 | + "beforeSuiteB", |
| 24 | + "beforeSuiteA", |
| 25 | + "beforeClassB", |
| 26 | + "beforeClassA", |
| 27 | + "beforeMethodB", |
| 28 | + "beforeMethodA", |
| 29 | + "TestB", |
| 30 | + "afterMethodB", |
| 31 | + "afterMethodA", |
| 32 | + "beforeMethodB", |
| 33 | + "beforeMethodA", |
| 34 | + "TestA", |
| 35 | + "afterMethodB", |
| 36 | + "afterMethodA", |
| 37 | + "afterClassB", |
| 38 | + "afterClassA", |
| 39 | + "afterSuiteB", |
| 40 | + "afterSuiteA"); |
| 41 | + assertThat(ConfigurationMethodPrioritySampleTest.logs).containsExactlyElementsOf(expectedLogs); |
| 42 | + } |
| 43 | + |
| 44 | + @Test(description = "GITHUB-2663") |
| 45 | + public void ensureThatPriorityWorksOnConfigurationMethodsWithGroupDependency() { |
| 46 | + List<String> expectedOrder1 = |
| 47 | + Arrays.asList( |
| 48 | + "s3", "s2", "s1", "t3", "t2", "t1", "c3", "c2", "c1", "m3", "m2", "m1", "test3", "m3", |
| 49 | + "m2", "m1", "test2", "m3", "m2", "m1", "test1"); |
| 50 | + TestNG tng = create(ConfigurationMethodPriorityWithGroupDependencySampleTest.class); |
| 51 | + InvokedMethodNameListener listener = new InvokedMethodNameListener(); |
| 52 | + tng.addListener(listener); |
| 53 | + tng.run(); |
| 54 | + System.out.println(expectedOrder1); |
| 55 | + System.out.println(listener.getSucceedMethodNames()); |
| 56 | + Assert.assertEquals(listener.getSucceedMethodNames(), expectedOrder1); |
| 57 | + } |
| 58 | + |
| 59 | + @Test(description = "GITHUB-2663") |
| 60 | + public void ensureThatPriorityWorksOnConfigurationMethodsWithMethodDependency() { |
| 61 | + List<String> expectedOrder1 = |
| 62 | + Arrays.asList( |
| 63 | + "s3", "s2", "s1", "t3", "t2", "t1", "c3", "c2", "c1", "m3", "m2", "m1", "test3", "m3", |
| 64 | + "m2", "m1", "test2", "m3", "m2", "m1", "test1"); |
| 65 | + TestNG tng = create(ConfigurationMethodPriorityWithMethodDependencySampleTest.class); |
| 66 | + InvokedMethodNameListener listener = new InvokedMethodNameListener(); |
| 67 | + tng.addListener(listener); |
| 68 | + tng.run(); |
| 69 | + System.out.println(expectedOrder1); |
| 70 | + System.out.println(listener.getSucceedMethodNames()); |
| 71 | + Assert.assertEquals(listener.getSucceedMethodNames(), expectedOrder1); |
| 72 | + } |
| 73 | +} |
0 commit comments