From 0bd597de427daaa546c8d96ccf7e4c32802bc572 Mon Sep 17 00:00:00 2001 From: Martin Aldrin Date: Mon, 25 Oct 2021 14:53:30 +0200 Subject: [PATCH] Add support for Priority in Configuration Methods --- CHANGES.txt | 3 +- .../org/testng/annotations/AfterClass.java | 7 ++ .../org/testng/annotations/AfterGroups.java | 7 ++ .../org/testng/annotations/AfterMethod.java | 7 ++ .../org/testng/annotations/AfterSuite.java | 7 ++ .../org/testng/annotations/AfterTest.java | 7 ++ .../org/testng/annotations/BeforeClass.java | 7 ++ .../org/testng/annotations/BeforeGroups.java | 7 ++ .../org/testng/annotations/BeforeMethod.java | 7 ++ .../org/testng/annotations/BeforeSuite.java | 7 ++ .../org/testng/annotations/BeforeTest.java | 7 ++ .../annotations/ITestOrConfiguration.java | 7 ++ .../org/testng/internal/ClonedMethod.java | 4 +- .../testng/internal/ConfigurationMethod.java | 2 + .../annotations/AnnotationHelper.java | 1 + .../internal/annotations/JDK15TagFactory.java | 12 +++ .../annotations/TestOrConfiguration.java | 1 + .../test/ConfigurationMethodPriorityTest.java | 68 +++++++++++++++ ...ConfigurationMethodPrioritySampleTest.java | 85 ++++++++++++++++++ ...PriorityWithGroupDependencySampleTest.java | 86 +++++++++++++++++++ ...riorityWithMethodDependencySampleTest.java | 86 +++++++++++++++++++ testng-core/src/test/resources/testng.xml | 7 ++ 22 files changed, 429 insertions(+), 3 deletions(-) create mode 100644 testng-core/src/test/java/test/ConfigurationMethodPriorityTest.java create mode 100644 testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPrioritySampleTest.java create mode 100644 testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithGroupDependencySampleTest.java create mode 100644 testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithMethodDependencySampleTest.java diff --git a/CHANGES.txt b/CHANGES.txt index 4c4cbcff96..312ae321e7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ Current -Fixed: GITHUB-2653: Assert methods requires casting since TestNg 7.0 for mixed boxed and unboxed primitives in assertEquals. +New: GITHUB-2663 Add support for Priority in Configuration Methods. (Martin Aldrin) +Fixed: GITHUB-2653: Assert methods requires casting since TestNg 7.0 for mixed boxed and unboxed primitives in assertEquals. (Martin Aldrin) Fixed: GITHUB-2229: Restore @BeforeGroups and @AfterGroups Annotations functionality (Krishnan Mahadevan) Fixed: GITHUB-2563: Skip test if its data provider provides no data (Krishnan Mahadevan) Fixed: GITHUB-2535: TestResult.getEndMillis() returns 0 for skipped configuration - after upgrading testng to 7.0 + (Krishnan Mahadevan) diff --git a/testng-core-api/src/main/java/org/testng/annotations/AfterClass.java b/testng-core-api/src/main/java/org/testng/annotations/AfterClass.java index 19654eafdb..414e2087ca 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/AfterClass.java +++ b/testng-core-api/src/main/java/org/testng/annotations/AfterClass.java @@ -77,4 +77,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/AfterGroups.java b/testng-core-api/src/main/java/org/testng/annotations/AfterGroups.java index f2bc0d03e7..ee80c1d722 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/AfterGroups.java +++ b/testng-core-api/src/main/java/org/testng/annotations/AfterGroups.java @@ -87,4 +87,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/AfterMethod.java b/testng-core-api/src/main/java/org/testng/annotations/AfterMethod.java index fbe135fe0c..e642db5b24 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/AfterMethod.java +++ b/testng-core-api/src/main/java/org/testng/annotations/AfterMethod.java @@ -99,4 +99,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/AfterSuite.java b/testng-core-api/src/main/java/org/testng/annotations/AfterSuite.java index 5cf961a8f6..7fc6cd6bbe 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/AfterSuite.java +++ b/testng-core-api/src/main/java/org/testng/annotations/AfterSuite.java @@ -77,4 +77,11 @@ * @return the valude (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/AfterTest.java b/testng-core-api/src/main/java/org/testng/annotations/AfterTest.java index 53344b25b2..134b9af7b0 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/AfterTest.java +++ b/testng-core-api/src/main/java/org/testng/annotations/AfterTest.java @@ -77,4 +77,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/BeforeClass.java b/testng-core-api/src/main/java/org/testng/annotations/BeforeClass.java index a9d2afe8c5..7446c4fab3 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/BeforeClass.java +++ b/testng-core-api/src/main/java/org/testng/annotations/BeforeClass.java @@ -77,4 +77,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/BeforeGroups.java b/testng-core-api/src/main/java/org/testng/annotations/BeforeGroups.java index b25a18494c..5aaef4d6f3 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/BeforeGroups.java +++ b/testng-core-api/src/main/java/org/testng/annotations/BeforeGroups.java @@ -87,4 +87,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/BeforeMethod.java b/testng-core-api/src/main/java/org/testng/annotations/BeforeMethod.java index 7eec50329a..1f2f487559 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/BeforeMethod.java +++ b/testng-core-api/src/main/java/org/testng/annotations/BeforeMethod.java @@ -99,4 +99,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/BeforeSuite.java b/testng-core-api/src/main/java/org/testng/annotations/BeforeSuite.java index c1f3d86e5b..94685dd001 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/BeforeSuite.java +++ b/testng-core-api/src/main/java/org/testng/annotations/BeforeSuite.java @@ -77,4 +77,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/BeforeTest.java b/testng-core-api/src/main/java/org/testng/annotations/BeforeTest.java index fee1b66603..ad17326575 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/BeforeTest.java +++ b/testng-core-api/src/main/java/org/testng/annotations/BeforeTest.java @@ -77,4 +77,11 @@ * @return the value (default 0) */ long timeOut() default 0; + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int priority() default 0; } diff --git a/testng-core-api/src/main/java/org/testng/annotations/ITestOrConfiguration.java b/testng-core-api/src/main/java/org/testng/annotations/ITestOrConfiguration.java index eedc55d359..805f5e867d 100644 --- a/testng-core-api/src/main/java/org/testng/annotations/ITestOrConfiguration.java +++ b/testng-core-api/src/main/java/org/testng/annotations/ITestOrConfiguration.java @@ -40,4 +40,11 @@ public interface ITestOrConfiguration extends IParameterizable { String getDescription(); void setDescription(String description); + + /** + * The scheduling priority. Lower priorities will be scheduled first. + * + * @return the value (default 0) + */ + int getPriority(); } diff --git a/testng-core/src/main/java/org/testng/internal/ClonedMethod.java b/testng-core/src/main/java/org/testng/internal/ClonedMethod.java index a7010a82ed..c49ad14381 100644 --- a/testng-core/src/main/java/org/testng/internal/ClonedMethod.java +++ b/testng-core/src/main/java/org/testng/internal/ClonedMethod.java @@ -327,7 +327,7 @@ public int getPriority() { @Override public void setPriority(int priority) { - // ignored + m_method.setPriority(priority); } @Override @@ -337,7 +337,7 @@ public int getInterceptedPriority() { @Override public void setInterceptedPriority(int priority) { - // ignored + m_method.setInterceptedPriority(priority); } @Override diff --git a/testng-core/src/main/java/org/testng/internal/ConfigurationMethod.java b/testng-core/src/main/java/org/testng/internal/ConfigurationMethod.java index a2b9f077be..cd17b1237d 100644 --- a/testng-core/src/main/java/org/testng/internal/ConfigurationMethod.java +++ b/testng-core/src/main/java/org/testng/internal/ConfigurationMethod.java @@ -409,6 +409,7 @@ private void init() { m_inheritGroupsFromTestClass = annotation.getInheritGroups(); setEnabled(annotation.getEnabled()); setDescription(annotation.getDescription()); + setPriority(annotation.getPriority()); } if (annotation != null && annotation.isFakeConfiguration()) { @@ -503,6 +504,7 @@ public ConfigurationMethod clone() { clone.setDescription(getDescription()); clone.setEnabled(getEnabled()); clone.setParameterInvocationCount(getParameterInvocationCount()); + clone.setPriority(getPriority()); clone.m_inheritGroupsFromTestClass = inheritGroupsFromTestClass(); return clone; diff --git a/testng-core/src/main/java/org/testng/internal/annotations/AnnotationHelper.java b/testng-core/src/main/java/org/testng/internal/annotations/AnnotationHelper.java index 3c13e0bd50..32c4f07037 100644 --- a/testng-core/src/main/java/org/testng/internal/annotations/AnnotationHelper.java +++ b/testng-core/src/main/java/org/testng/internal/annotations/AnnotationHelper.java @@ -197,6 +197,7 @@ private static void finishInitialize( result.setGroups(bs.getGroups()); result.setInheritGroups(bs.getInheritGroups()); result.setTimeOut(bs.getTimeOut()); + result.setPriority(bs.getPriority()); } public static List> getAllAnnotations() { diff --git a/testng-core/src/main/java/org/testng/internal/annotations/JDK15TagFactory.java b/testng-core/src/main/java/org/testng/internal/annotations/JDK15TagFactory.java index bdca20e6be..fd74018c62 100644 --- a/testng-core/src/main/java/org/testng/internal/annotations/JDK15TagFactory.java +++ b/testng-core/src/main/java/org/testng/internal/annotations/JDK15TagFactory.java @@ -109,6 +109,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IAfterSuite.class) { AfterSuite bs = (AfterSuite) a; @@ -136,6 +137,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IBeforeTest.class) { BeforeTest bs = (BeforeTest) a; @@ -163,6 +165,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IAfterTest.class) { AfterTest bs = (AfterTest) a; @@ -190,6 +193,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IBeforeGroups.class) { BeforeGroups bs = (BeforeGroups) a; @@ -218,6 +222,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IAfterGroups.class) { AfterGroups bs = (AfterGroups) a; @@ -246,6 +251,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IBeforeClass.class) { BeforeClass bs = (BeforeClass) a; @@ -273,6 +279,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IAfterClass.class) { AfterClass bs = (AfterClass) a; @@ -300,6 +307,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, false, bs.timeOut(), + bs.priority(), new String[0]); } else if (annotationClass == IBeforeMethod.class) { BeforeMethod bs = (BeforeMethod) a; @@ -327,6 +335,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota bs.firstTimeOnly(), false, bs.timeOut(), + bs.priority(), bs.onlyForGroups()); } else if (annotationClass == IAfterMethod.class) { AfterMethod bs = (AfterMethod) a; @@ -354,6 +363,7 @@ private IAnnotation maybeCreateNewConfigurationTag(Annotation a, Class annota false, bs.lastTimeOnly(), bs.timeOut(), + bs.priority(), bs.onlyForGroups()); } @@ -383,6 +393,7 @@ private IAnnotation createConfigurationTag( boolean firstTimeOnly, boolean lastTimeOnly, long timeOut, + int priority, String[] groupFilters) { ConfigurationAnnotation result = new ConfigurationAnnotation(); result.setIsBeforeGroups(isBeforeGroups); @@ -410,6 +421,7 @@ private IAnnotation createConfigurationTag( result.setFirstTimeOnly(firstTimeOnly); result.setLastTimeOnly(lastTimeOnly); result.setTimeOut(timeOut); + result.setPriority(priority); return result; } diff --git a/testng-core/src/main/java/org/testng/internal/annotations/TestOrConfiguration.java b/testng-core/src/main/java/org/testng/internal/annotations/TestOrConfiguration.java index f924b887e0..2f245c3dce 100644 --- a/testng-core/src/main/java/org/testng/internal/annotations/TestOrConfiguration.java +++ b/testng-core/src/main/java/org/testng/internal/annotations/TestOrConfiguration.java @@ -62,6 +62,7 @@ public void setDescription(String description) { m_description = description; } + @Override public int getPriority() { return m_priority; } diff --git a/testng-core/src/test/java/test/ConfigurationMethodPriorityTest.java b/testng-core/src/test/java/test/ConfigurationMethodPriorityTest.java new file mode 100644 index 0000000000..af35b71e83 --- /dev/null +++ b/testng-core/src/test/java/test/ConfigurationMethodPriorityTest.java @@ -0,0 +1,68 @@ +package test; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; +import java.util.List; + +import org.testng.Assert; +import org.testng.TestNG; +import org.testng.annotations.Test; + +import test.configuration.issue2663.ConfigurationMethodPrioritySampleTest; +import test.configuration.issue2663.ConfigurationMethodPriorityWithGroupDependencySampleTest; + +public class ConfigurationMethodPriorityTest extends SimpleBaseTest { + + @Test(description = "GITHUB-2663") + public void ensureThatPriorityWorksOnConfigurationMethods() { + TestNG testng = create(ConfigurationMethodPrioritySampleTest.class); + testng.run(); + assertThat(testng.getStatus()).isEqualTo(0); + List expectedLogs = + Arrays.asList( + "beforeSuiteB", + "beforeSuiteA", + "beforeClassB", + "beforeClassA", + "beforeMethodB", + "beforeMethodA", + "TestB", + "afterMethodB", + "afterMethodA", + "beforeMethodB", + "beforeMethodA", + "TestA", + "afterMethodB", + "afterMethodA", + "afterClassB", + "afterClassA", + "afterSuiteB", + "afterSuiteA"); + assertThat(ConfigurationMethodPrioritySampleTest.logs).containsExactlyElementsOf(expectedLogs); + } + @Test + public void ensureThatPriorityWorksOnConfigurationMethodsWithGroupDependency() { + List expectedOrder1 = Arrays.asList("s1", "s2", "s3","t1", "t2", "t3","c1", "c2", "c3","m1", "m2", "m3","test1","m1", "m2", "m3","test2","m1", "m2", "m3","test3"); + TestNG tng = create(ConfigurationMethodPriorityWithGroupDependencySampleTest.class); + InvokedMethodNameListener listener = new InvokedMethodNameListener(); + tng.addListener(listener); + tng.run(); + System.out.println(expectedOrder1); + System.out.println(listener.getSucceedMethodNames()); + Assert.assertEquals(listener.getSucceedMethodNames(), expectedOrder1); + } + + @Test + public void ensureThatPriorityWorksOnConfigurationMethodsWithMethodDependency() { + List expectedOrder1 = Arrays.asList("s1", "s2", "s3","t1", "t2", "t3","c1", "c2", "c3","m1", "m2", "m3","test1","m1", "m2", "m3","test2","m1", "m2", "m3","test3"); + TestNG tng = create(ConfigurationMethodPriorityWithGroupDependencySampleTest.class); + InvokedMethodNameListener listener = new InvokedMethodNameListener(); + tng.addListener(listener); + tng.run(); + System.out.println(expectedOrder1); + System.out.println(listener.getSucceedMethodNames()); + Assert.assertEquals(listener.getSucceedMethodNames(), expectedOrder1); + } + +} diff --git a/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPrioritySampleTest.java b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPrioritySampleTest.java new file mode 100644 index 0000000000..62acf93fb2 --- /dev/null +++ b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPrioritySampleTest.java @@ -0,0 +1,85 @@ +package test.configuration.issue2663; + +import java.util.ArrayList; +import java.util.List; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Test; + +public class ConfigurationMethodPrioritySampleTest { + public static List logs = new ArrayList<>(); + + @BeforeSuite(priority = 100) + public void beforeSuiteA() { + logs.add("beforeSuiteA"); + } + + @BeforeSuite(priority = 1) + public void beforeSuiteB() { + logs.add("beforeSuiteB"); + } + + @BeforeClass(priority = 100) + public void beforeClassA() { + logs.add("beforeClassA"); + } + + @BeforeClass(priority = 1) + public void beforeClassB() { + logs.add("beforeClassB"); + } + + @BeforeMethod(priority = 100) + public void beforeMethodA() { + logs.add("beforeMethodA"); + } + + @BeforeMethod(priority = 1) + public void beforeMethodB() { + logs.add("beforeMethodB"); + } + + @Test(priority = 100) + public void testA() { + logs.add("TestA"); + } + + @Test(priority = 0) + public void testB() { + logs.add("TestB"); + } + + @AfterSuite(priority = 100) + public void afterSuiteA() { + logs.add("afterSuiteA"); + } + + @AfterSuite(priority = 1) + public void afterSuiteB() { + logs.add("afterSuiteB"); + } + + @AfterClass(priority = 100) + public void afterClassA() { + logs.add("afterClassA"); + } + + @AfterClass(priority = 1) + public void afterClassB() { + logs.add("afterClassB"); + } + + @AfterMethod(priority = 100) + public void afterMethodA() { + logs.add("afterMethodA"); + } + + @AfterMethod(priority = 1) + public void afterMethodB() { + logs.add("afterMethodB"); + } +} diff --git a/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithGroupDependencySampleTest.java b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithGroupDependencySampleTest.java new file mode 100644 index 0000000000..dd226c5b2d --- /dev/null +++ b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithGroupDependencySampleTest.java @@ -0,0 +1,86 @@ +package test.configuration.issue2663; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +public class ConfigurationMethodPriorityWithGroupDependencySampleTest { + + @BeforeSuite(groups = { "g1" }, priority = 2) + public void s1() { + System.out.println("s1"); + } + + @BeforeSuite(groups = { "g2" }, dependsOnGroups = "g1", priority = 0) + public void s2() { + System.out.println("s2"); + } + + @BeforeSuite(groups = { "g2" }, dependsOnGroups = "g1", priority = 1) + public void s3() { + System.out.println("s3"); + } + + @BeforeClass(groups = { "g1" }, priority = 2) + public void c1() { + System.out.println("c1"); + } + + @BeforeClass(groups = { "g2" }, dependsOnGroups = "g1", priority = 0) + public void c2() { + System.out.println("c2"); + } + + @BeforeClass(groups = { "g2" }, dependsOnGroups = "g1", priority = 1) + public void c3() { + System.out.println("c3"); + } + + @BeforeTest(groups = { "g1" }, priority = 2) + public void t1() { + System.out.println("t1"); + } + + @BeforeTest(groups = { "g2" }, dependsOnGroups = "g1", priority = 0) + public void t2() { + System.out.println("t2"); + } + + @BeforeTest(groups = { "g2" }, dependsOnGroups = "g1", priority = 1) + public void t3() { + System.out.println("t3"); + } + + @BeforeMethod(groups = { "g1" }, priority = 2) + public void m1() { + System.out.println("m1"); + } + + @BeforeMethod(groups = { "g2" }, dependsOnGroups = "g1", priority = 0) + public void m2() { + System.out.println("m2"); + } + + @BeforeMethod(groups = { "g2" }, dependsOnGroups = "g1", priority = 1) + public void m3() { + System.out.println("m3"); + } + + @Test(groups = { "g1" }) + public void test1() { + System.out.println("test1"); + } + + @Test(groups = { "g2" }) + public void test2() { + System.out.println("test2"); + } + + @Test(groups = { "g3" }) + public void test3() { + System.out.println("test3"); + } + +} diff --git a/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithMethodDependencySampleTest.java b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithMethodDependencySampleTest.java new file mode 100644 index 0000000000..062072771f --- /dev/null +++ b/testng-core/src/test/java/test/configuration/issue2663/ConfigurationMethodPriorityWithMethodDependencySampleTest.java @@ -0,0 +1,86 @@ +package test.configuration.issue2663; + +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +public class ConfigurationMethodPriorityWithMethodDependencySampleTest { + + @BeforeSuite(priority = 2) + public void s1() { + System.out.println("s1"); + } + + @BeforeSuite(dependsOnMethods = "s1", priority = 0) + public void s2() { + System.out.println("s2"); + } + + @BeforeSuite(dependsOnMethods = "s1", priority = 1) + public void s3() { + System.out.println("s3"); + } + + @BeforeClass(priority = 2) + public void c1() { + System.out.println("c1"); + } + + @BeforeClass(dependsOnMethods = "c1", priority = 0) + public void c2() { + System.out.println("c2"); + } + + @BeforeClass(dependsOnMethods = "c1", priority = 1) + public void c3() { + System.out.println("c3"); + } + + @BeforeTest(priority = 2) + public void t1() { + System.out.println("t1"); + } + + @BeforeTest(dependsOnMethods = "t1", priority = 0) + public void t2() { + System.out.println("t2"); + } + + @BeforeTest(dependsOnMethods = "t1", priority = 1) + public void t3() { + System.out.println("t3"); + } + + @BeforeMethod(priority = 2) + public void m1() { + System.out.println("m1"); + } + + @BeforeMethod(dependsOnMethods = "m1", priority = 0) + public void m2() { + System.out.println("m2"); + } + + @BeforeMethod(dependsOnMethods = "m1", priority = 1) + public void m3() { + System.out.println("m3"); + } + + @Test(groups = { "g1" }) + public void test1() { + System.out.println("test1"); + } + + @Test(groups = { "g2" }) + public void test2() { + System.out.println("test2"); + } + + @Test(groups = { "g3" }) + public void test3() { + System.out.println("test3"); + } + +} diff --git a/testng-core/src/test/resources/testng.xml b/testng-core/src/test/resources/testng.xml index 7a7eb4baad..59014b4835 100644 --- a/testng-core/src/test/resources/testng.xml +++ b/testng-core/src/test/resources/testng.xml @@ -996,4 +996,11 @@ + + + + + + +