Skip to content

Commit ca6c384

Browse files
authored
Merge pull request #134 from magento-commerce/MQE-2669_alex
MQE-2669: Seprated a run:failed command to generate:failed and run:fa…
2 parents 9fb3fdc + 68e0ee8 commit ca6c384

File tree

82 files changed

+620
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+620
-57
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\Console;
8+
9+
use Magento\FunctionalTestingFramework\Console\RunTestFailedCommand;
10+
11+
class RunTestFailedCommandTest extends BaseGenerateCommandTest
12+
{
13+
/**
14+
* @throws \ReflectionException
15+
*/
16+
public function testMultipleTests(): void
17+
{
18+
$testFailedFile = [
19+
"tests/functional/tests/MFTF/_generated/default/SingleTestNoSuiteTest.php:SingleTestNoSuiteTest",
20+
"tests/functional/tests/MFTF/_generated/SomeSpecificSuite/FirstTestSuiteTest.php:SingleTestSuiteTest",
21+
"tests/functional/tests/MFTF/_generated/SomeSpecificSuite/SecondTestNoSuiteTest.php:SingleTestNoSuiteTest",
22+
"tests/functional/tests/MFTF/_generated/SomeOtherSuite/SecondTestNoSuiteTest.php:SingleTestNoSuiteTest",
23+
];
24+
25+
$expectedResult = [
26+
"tests/functional/tests/MFTF/_generated/default/SingleTestNoSuiteTest.php",
27+
"-g SomeSpecificSuite",
28+
"-g SomeOtherSuite",
29+
];
30+
31+
$runFailed = new RunTestFailedCommand('run:failed');
32+
$filter = $this->invokePrivateMethod($runFailed, 'filterTestsForExecution', [$testFailedFile]);
33+
$this->assertEquals($expectedResult, $filter);
34+
}
35+
36+
/**
37+
* Invoking private method to be able to test it.
38+
* NOTE: Bad practice don't repeat it.
39+
*
40+
* @param $object
41+
* @param $methodName
42+
* @param array $parameters
43+
* @return mixed
44+
* @throws \ReflectionException
45+
*/
46+
private function invokePrivateMethod(&$object, $methodName, array $parameters = [])
47+
{
48+
$reflection = new \ReflectionClass(get_class($object));
49+
$method = $reflection->getMethod($methodName);
50+
$method->setAccessible(true);
51+
return $method->invokeArgs($object, $parameters);
52+
}
53+
}

dev/tests/verification/Resources/ActionGroupContainsStepKeyInArgText.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ class ActionGroupContainsStepKeyInArgTextCest
4141
$I->see("arg1", ".selector"); // stepKey: arg1ActionGroup
4242
$I->comment("Exiting Action Group [actionGroup] actionGroupContainsStepKeyInArgValue");
4343
}
44+
45+
public function _passed(AcceptanceTester $I)
46+
{
47+
// Deleting itself so that we can rerun only failed tests.
48+
unlink(__FILE__);
49+
}
4450
}

dev/tests/verification/Resources/ActionGroupMergedViaInsertAfter.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ class ActionGroupMergedViaInsertAfterCest
3535
$I->fillField("#baz", "baz"); // stepKey: fillField3Keyone
3636
$I->comment("Exiting Action Group [keyone] FunctionalActionGroupForMassMergeAfter");
3737
}
38+
39+
public function _passed(AcceptanceTester $I)
40+
{
41+
// Deleting itself so that we can rerun only failed tests.
42+
unlink(__FILE__);
43+
}
3844
}

dev/tests/verification/Resources/ActionGroupMergedViaInsertBefore.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ class ActionGroupMergedViaInsertBeforeCest
3535
$I->fillField("#baz", "baz"); // stepKey: fillField3Keyone
3636
$I->comment("Exiting Action Group [keyone] FunctionalActionGroupForMassMergeBefore");
3737
}
38+
39+
public function _passed(AcceptanceTester $I)
40+
{
41+
// Deleting itself so that we can rerun only failed tests.
42+
unlink(__FILE__);
43+
}
3844
}

dev/tests/verification/Resources/ActionGroupReturningValueTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ class ActionGroupReturningValueTestCest
7272
$I->see($actionGroupWithReturnValue1, "#element .{$actionGroupWithReturnValue1}"); // stepKey: see1ActionGroupWithStringUsage1
7373
$I->comment("Exiting Action Group [actionGroupWithStringUsage1] actionGroupWithStringUsage");
7474
}
75+
76+
public function _passed(AcceptanceTester $I)
77+
{
78+
// Deleting itself so that we can rerun only failed tests.
79+
unlink(__FILE__);
80+
}
7581
}

dev/tests/verification/Resources/ActionGroupToExtend.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ class ActionGroupToExtendCest
3131
$I->assertCount(99, $grabProductsActionGroup); // stepKey: assertCountActionGroup
3232
$I->comment("Exiting Action Group [actionGroup] ActionGroupToExtend");
3333
}
34+
35+
public function _passed(AcceptanceTester $I)
36+
{
37+
// Deleting itself so that we can rerun only failed tests.
38+
unlink(__FILE__);
39+
}
3440
}

dev/tests/verification/Resources/ActionGroupUsingCreateData.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ class ActionGroupUsingCreateDataCest
3939
public function ActionGroupUsingCreateData(AcceptanceTester $I)
4040
{
4141
}
42+
43+
public function _passed(AcceptanceTester $I)
44+
{
45+
// Deleting itself so that we can rerun only failed tests.
46+
unlink(__FILE__);
47+
}
4248
}

dev/tests/verification/Resources/ActionGroupUsingNestedArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,10 @@ class ActionGroupUsingNestedArgumentCest
3131
$I->assertCount(99, $grabProductsActionGroup); // stepKey: assertCountActionGroup
3232
$I->comment("Exiting Action Group [actionGroup] ActionGroupToExtend");
3333
}
34+
35+
public function _passed(AcceptanceTester $I)
36+
{
37+
// Deleting itself so that we can rerun only failed tests.
38+
unlink(__FILE__);
39+
}
3440
}

dev/tests/verification/Resources/ActionGroupWithDataOverrideTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,10 @@ class ActionGroupWithDataOverrideTestCest
7373
$I->comment("Exiting Action Group [actionGroupWithDataOverride1] FunctionalActionGroupWithData");
7474
$I->click("loginButton"); // stepKey: step6
7575
}
76+
77+
public function _passed(AcceptanceTester $I)
78+
{
79+
// Deleting itself so that we can rerun only failed tests.
80+
unlink(__FILE__);
81+
}
7682
}

dev/tests/verification/Resources/ActionGroupWithDataTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,10 @@ class ActionGroupWithDataTestCest
7373
$I->comment("Exiting Action Group [actionGroupWithData1] FunctionalActionGroupWithData");
7474
$I->click("loginButton"); // stepKey: step6
7575
}
76+
77+
public function _passed(AcceptanceTester $I)
78+
{
79+
// Deleting itself so that we can rerun only failed tests.
80+
unlink(__FILE__);
81+
}
7682
}

dev/tests/verification/Resources/ActionGroupWithDefaultArgumentAndStringSelectorParam.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithDefaultArgumentAndStringSelectorParamCest
3232
$I->see("John", "#element .test1"); // stepKey: seeFirstNameActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithMultipleParameterSelectorsFromDefaultArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithMultipleParameterSelectorsFromDefaultArgumentCest
3232
$I->see("Doe", "#John-Doe .test"); // stepKey: seeLastNameActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithMultipleParameterSelectorsFromArgument");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithNoArguments.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithNoArgumentsCest
3232
$I->wait(1); // stepKey: waitForNothingActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithoutArguments");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithNoDefaultTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ class ActionGroupWithNoDefaultTestCest
7171
$I->comment("Exiting Action Group [actionGroupWithDataOverride1] FunctionalActionGroupNoDefault");
7272
$I->click("loginButton"); // stepKey: step6
7373
}
74+
75+
public function _passed(AcceptanceTester $I)
76+
{
77+
// Deleting itself so that we can rerun only failed tests.
78+
unlink(__FILE__);
79+
}
7480
}

dev/tests/verification/Resources/ActionGroupWithParameterizedElementWithHyphen.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ class ActionGroupWithParameterizedElementWithHyphenCest
3030
$keyoneActionGroup = $I->executeJS("#element .full-width"); // stepKey: keyoneActionGroup
3131
$I->comment("Exiting Action Group [actionGroup] SectionArgumentWithParameterizedSelector");
3232
}
33+
34+
public function _passed(AcceptanceTester $I)
35+
{
36+
// Deleting itself so that we can rerun only failed tests.
37+
unlink(__FILE__);
38+
}
3339
}

dev/tests/verification/Resources/ActionGroupWithParameterizedElementsWithStepKeyReferences.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ class ActionGroupWithParameterizedElementsWithStepKeyReferencesCest
3535
$I->seeElement("//div[@name='Tiberius'][@class={$testVariableActionGroup}][@data-element='{$testVariable2ActionGroup}'][" . $I->retrieveEntityField('createSimpleData', 'name', 'test') . "]"); // stepKey: see1ActionGroup
3636
$I->comment("Exiting Action Group [actionGroup] actionGroupWithParametrizedSelectors");
3737
}
38+
39+
public function _passed(AcceptanceTester $I)
40+
{
41+
// Deleting itself so that we can rerun only failed tests.
42+
unlink(__FILE__);
43+
}
3844
}

dev/tests/verification/Resources/ActionGroupWithPassedArgumentAndStringSelectorParam.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithPassedArgumentAndStringSelectorParamCest
3232
$I->see("John" . msq("UniquePerson"), "#element .test1"); // stepKey: seeFirstNameActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithDefaultArgumentAndStringSelectorParam");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithPersistedData.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ class ActionGroupWithPersistedDataCest
7272
$I->see("#element ." . $I->retrieveEntityField('createPerson', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1
7373
$I->comment("Exiting Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData");
7474
}
75+
76+
public function _passed(AcceptanceTester $I)
77+
{
78+
// Deleting itself so that we can rerun only failed tests.
79+
unlink(__FILE__);
80+
}
7581
}

dev/tests/verification/Resources/ActionGroupWithSectionAndDataAsArguments.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,10 @@ class ActionGroupWithSectionAndDataAsArgumentsCest
3030
$I->waitForElementVisible("#element .John", 10); // stepKey: arg1ActionGroup
3131
$I->comment("Exiting Action Group [actionGroup] actionGroupWithSectionAndData");
3232
}
33+
34+
public function _passed(AcceptanceTester $I)
35+
{
36+
// Deleting itself so that we can rerun only failed tests.
37+
unlink(__FILE__);
38+
}
3339
}

dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromDefaultArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithSimpleDataUsageFromDefaultArgumentCest
3232
$I->see("stringLiteral", "#element .stringLiteral"); // stepKey: see1ActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithStringUsage");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithSimpleDataUsageFromPassedArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,10 @@ class ActionGroupWithSimpleDataUsageFromPassedArgumentCest
5959
$I->see($I->retrieveEntityField('simpleData', 'firstname[data_index]', 'test'), "#element ." . $I->retrieveEntityField('simpleData', 'firstname[data_index]', 'test')); // stepKey: see1ActionGroup7
6060
$I->comment("Exiting Action Group [actionGroup7] actionGroupWithEntityUsage");
6161
}
62+
63+
public function _passed(AcceptanceTester $I)
64+
{
65+
// Deleting itself so that we can rerun only failed tests.
66+
unlink(__FILE__);
67+
}
6268
}

dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromDefaultArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithSingleParameterSelectorFromDefaultArgumentCest
3232
$I->see("Doe", "#element .John"); // stepKey: seeLastNameActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithSingleParameterSelectorFromArgument");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithSingleParameterSelectorFromPassedArgument.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ class ActionGroupWithSingleParameterSelectorFromPassedArgumentCest
3232
$I->see("Doe", "#element .John" . msq("UniquePerson")); // stepKey: seeLastNameActionGroup
3333
$I->comment("Exiting Action Group [actionGroup] actionGroupWithSingleParameterSelectorFromArgument");
3434
}
35+
36+
public function _passed(AcceptanceTester $I)
37+
{
38+
// Deleting itself so that we can rerun only failed tests.
39+
unlink(__FILE__);
40+
}
3541
}

dev/tests/verification/Resources/ActionGroupWithStepKeyReferences.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ class ActionGroupWithStepKeyReferencesCest
5555
$action16ActionGroup = $I->grabValueFrom($action16ActionGroup); // stepKey: action16ActionGroup
5656
$I->comment("Exiting Action Group [actionGroup] FunctionActionGroupWithStepKeyReferences");
5757
}
58+
59+
public function _passed(AcceptanceTester $I)
60+
{
61+
// Deleting itself so that we can rerun only failed tests.
62+
unlink(__FILE__);
63+
}
5864
}

dev/tests/verification/Resources/ActionGroupWithTopLevelPersistedData.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,10 @@ class ActionGroupWithTopLevelPersistedDataCest
7171
$I->see("#element ." . $I->retrieveEntityField('createPersonParam', 'firstname', 'test')); // stepKey: see1ActionGroupWithPersistedData1
7272
$I->comment("Exiting Action Group [actionGroupWithPersistedData1] FunctionalActionGroupWithData");
7373
}
74+
75+
public function _passed(AcceptanceTester $I)
76+
{
77+
// Deleting itself so that we can rerun only failed tests.
78+
unlink(__FILE__);
79+
}
7480
}

dev/tests/verification/Resources/ActionsInDifferentModulesSuite.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class ActionsInDifferentModulesSuite extends \Codeception\GroupObject
5151
private function executePreConditions()
5252
{
5353
if ($this->currentTestRun == 1) {
54+
$this->testCount = $this->getTestCount();
55+
5456
print sprintf(self::$HOOK_EXECUTION_INIT, "before");
5557

5658
try {
@@ -215,4 +217,28 @@ class ActionsInDifferentModulesSuite extends \Codeception\GroupObject
215217
}
216218
return $module;
217219
}
220+
221+
/**
222+
* Counts how many tests in group.
223+
*
224+
* @return integer
225+
*/
226+
private function getTestCount()
227+
{
228+
$config = $this->getGlobalConfig();
229+
if (empty($config['groups']) || empty($config['groups'][self::$group])) {
230+
return $this->testCount;
231+
}
232+
$pathToGroupDir = TESTS_BP . DIRECTORY_SEPARATOR . array_first($config['groups'][self::$group]);
233+
$pathToGroupCests = $pathToGroupDir . "*Cest.php";
234+
235+
$files = glob($pathToGroupCests);
236+
if (is_array($files)) {
237+
$qty = count($files);
238+
print('In a group "' . self::$group . '" suite executor found ' . $qty . ' tests.' . PHP_EOL);
239+
return $qty;
240+
}
241+
242+
return $this->testCount;
243+
}
218244
}

dev/tests/verification/Resources/ArgumentWithSameNameAsElement.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ class ArgumentWithSameNameAsElementCest
6868
$I->seeElement("#element .John"); // stepKey: see2ActionGroup1
6969
$I->comment("Exiting Action Group [actionGroup1] FunctionalActionGroupWithTrickyArgument");
7070
}
71+
72+
public function _passed(AcceptanceTester $I)
73+
{
74+
// Deleting itself so that we can rerun only failed tests.
75+
unlink(__FILE__);
76+
}
7177
}

dev/tests/verification/Resources/AssertTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,10 @@ class AssertTestCest
160160
$I->assertNotRegExp('/placeholder\/thumbnail\.jpg/', $getSimpleProductThumbnail); // stepKey: simpleThumbnailIsNotDefault
161161
$I->assertRegExp("#var\s+adminAnalyticsMetadata\s+=\s+{\s+(\"[\w_]+\":\s+\"[^\"]*?\",\s+)*?(\"[\w_]+\":\s+\"[^\"]*?\"\s+)};#s", $pageSource, "adminAnalyticsMetadata object is invalid"); // stepKey: validateadminAnalyticsMetadata
162162
}
163+
164+
public function _passed(AcceptanceTester $I)
165+
{
166+
// Deleting itself so that we can rerun only failed tests.
167+
unlink(__FILE__);
168+
}
163169
}

dev/tests/verification/Resources/BasicActionGroupTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ class BasicActionGroupTestCest
4949
$I->comment("Exiting Action Group [actionGroup1] FunctionalActionGroup");
5050
$I->click("loginButton"); // stepKey: step6
5151
}
52+
53+
public function _passed(AcceptanceTester $I)
54+
{
55+
// Deleting itself so that we can rerun only failed tests.
56+
unlink(__FILE__);
57+
}
5258
}

dev/tests/verification/Resources/BasicFunctionalTest.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,10 @@ class BasicFunctionalTestCest
185185
$I->waitForJS("someJsFunction", 30); // stepKey: waitForJSKey1
186186
$I->waitForText("someInput", 30, ".functionalTestSelector"); // stepKey: waitForText1
187187
}
188+
189+
public function _passed(AcceptanceTester $I)
190+
{
191+
// Deleting itself so that we can rerun only failed tests.
192+
unlink(__FILE__);
193+
}
188194
}

0 commit comments

Comments
 (0)