diff --git a/CHANGELOG.md b/CHANGELOG.md index 73fb5e4b..44308e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * **(breaking change)** [#246 Changes to ConfigValueHandlerPhased](https://github.com/adobe/phased-testing/issues/246). The public field `ConfigValueHandlerPhased.deprecatedSystemName` has been renamed to `legacySystemName`, to reflect that these are old property names still fully supported, not deprecated ones. In addition, `MutationListener` now proactively checks all config values at suite start and logs a warning for any legacy property name that is in use, rather than only warning the first time the value is fetched. * [#251 Add a boolean to ConfigValueHandler that is deprecation](https://github.com/adobe/phased-testing/issues/251). `ConfigValueHandlerPhased` now has a `description` field (populated for every config value) and a `deprecated` boolean, to distinguish a property whose usage itself is going away from one that has simply been renamed (see #246). `PHASED.TESTS.PHASE` and `PHASED.TESTS.NONPHASED.LEGACY` are marked deprecated. `MutationListener` now also warns at suite start if a deprecated property is set, using its description to explain why. * [#227 NIE: rename waitTillFinished to a better wording](https://github.com/adobe/phased-testing/issues/227). `NonInterruptiveEvent.waitTillFinished()` has been renamed to `waitTillStarted()`, since it waits for the startUp stage to be finalized rather than for the event to finish. `waitTillFinished()` is now `@Deprecated` and still fully functional (it forwards to/from `waitTillStarted()`), so existing subclasses of `NonInterruptiveEvent` do not need to change. It will be removed in a future major version. +* [#106 Include factory in the filters for the order](https://github.com/adobe/phased-testing/issues/106). `@DataProvider` and `@Factory` annotated methods are now excluded from Permutation Execution Mode step ordering, the same way `@Before*`/`@After*` methods already are. * **New Environment Variables** * MUTATIONAL.EXECUTION.MODE : This property is used to set the execution mode of the Mutational Tests. The value can be one of the following: STANDARD, INTERRUPTIVE(PRODUCER), INTERRUPTIVE(CONSUMER), NON-INTERRUPTIVE, PERMUATIONAL. This will replace the PHASED.TESTS.PHASE property which will be removed in 9.X.3. diff --git a/phased-testing-core/src/main/java/com/adobe/campaign/tests/integro/phased/stepdependencies/ScenarioStepDependencyFactory.java b/phased-testing-core/src/main/java/com/adobe/campaign/tests/integro/phased/stepdependencies/ScenarioStepDependencyFactory.java index 4222ea35..f68b4285 100644 --- a/phased-testing-core/src/main/java/com/adobe/campaign/tests/integro/phased/stepdependencies/ScenarioStepDependencyFactory.java +++ b/phased-testing-core/src/main/java/com/adobe/campaign/tests/integro/phased/stepdependencies/ScenarioStepDependencyFactory.java @@ -29,7 +29,7 @@ public class ScenarioStepDependencyFactory { private static final List CONFIG_CLASSES = Arrays.asList(BeforeClass.class, BeforeMethod.class, BeforeSuite.class, BeforeGroups.class, BeforeTest.class, AfterClass.class, AfterMethod.class, AfterSuite.class, AfterGroups.class, - AfterTest.class); + AfterTest.class, DataProvider.class, Factory.class); /** * From a class, this method returns the methods, and what they produce / consume diff --git a/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/data/permutational/ProducerConsumerWithDataProviderAndFactory.java b/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/data/permutational/ProducerConsumerWithDataProviderAndFactory.java new file mode 100644 index 00000000..0e8207db --- /dev/null +++ b/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/data/permutational/ProducerConsumerWithDataProviderAndFactory.java @@ -0,0 +1,33 @@ +/* + * Copyright 2022 Adobe + * All Rights Reserved. + * + * NOTICE: Adobe permits you to use, modify, and distribute this file in + * accordance with the terms of the Adobe license agreement accompanying + * it. + */ +package com.adobe.campaign.tests.integro.phased.data.permutational; + +import com.adobe.campaign.tests.integro.phased.PhasedTestManager; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Factory; + +public class ProducerConsumerWithDataProviderAndFactory { + @Factory + public Object[] createInstances() { + return new Object[0]; + } + + @DataProvider(name = "myDataProvider") + public Object[][] provideData() { + return new Object[][] { { "value" } }; + } + + public void bbbbb(Object param) { + PhasedTestManager.produce("bbbbkey","bbbbValue"); + } + + public void aaaa(Object param) { + PhasedTestManager.consume("bbbbkey"); + } +} diff --git a/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/stepdependencies/TestExtractingDependencies.java b/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/stepdependencies/TestExtractingDependencies.java index b6146e7a..71c5fb2a 100644 --- a/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/stepdependencies/TestExtractingDependencies.java +++ b/phased-testing-testng/src/test/java/com/adobe/campaign/tests/integro/phased/stepdependencies/TestExtractingDependencies.java @@ -307,6 +307,29 @@ public void testFetchExtractingProduceConsumeWithBeforeMethod() Collectors.toList()), contains("bbbbb", "aaaa")); } + @Test + public void testFetchExtractingProduceConsumeWithDataProviderAndFactory() + throws NoSuchMethodException, SecurityException, IOException { + + Class l_testClass = ProducerConsumerWithDataProviderAndFactory.class; + + ScenarioStepDependencies dependencies = ScenarioStepDependencyFactory.listMethodCalls(l_testClass); + + assertThat("We should have fetched the correct methods", dependencies.getStepDependencies().keySet(), + containsInAnyOrder("createInstances", "provideData", "bbbbb", "aaaa")); + + assertThat("The @Factory method should be a config method", + dependencies.getStep("createInstances").isConfigMethod()); + assertThat("The @DataProvider method should be a config method", + dependencies.getStep("provideData").isConfigMethod()); + assertThat("This test should be a test", !dependencies.getStep("bbbbb").isConfigMethod()); + assertThat("This test should be a test", !dependencies.getStep("aaaa").isConfigMethod()); + + assertThat("The ordered set should exclude @Factory and @DataProvider methods", + dependencies.fetchExecutionOrderList().stream().map(f -> f.getStepName()).collect( + Collectors.toList()), contains("bbbbb", "aaaa")); + } + @Test public void testListMethodCalls_negativeFileNotFound() throws NoSuchMethodException, SecurityException, IOException {