Skip to content

Commit 68e0ee8

Browse files
committed
MQE-2669: Seprated a run:failed command to generate:failed and run:failed
- add a simple unit test
1 parent a3274a3 commit 68e0ee8

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
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+
}

src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RunTestFailedCommand extends BaseGenerateCommand
2323
/**
2424
* @var string
2525
*/
26-
private $testsReRunFile = "";
26+
private $testsReRunFile = "rerun_tests";
2727

2828
/**
2929
* @var array

0 commit comments

Comments
 (0)