@@ -23,11 +23,6 @@ class GenerateTestFailedCommand extends BaseGenerateCommand
2323 */
2424 const DEFAULT_TEST_GROUP = 'default ' ;
2525
26- /**
27- * @var string
28- */
29- private $ testsReRunFile ;
30-
3126 /**
3227 * Configures the current command.
3328 *
@@ -54,9 +49,6 @@ protected function configure()
5449 */
5550 protected function execute (InputInterface $ input , OutputInterface $ output ): int
5651 {
57- $ this ->testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
58- $ this ->testsReRunFile = $ this ->getTestsOutputDir () . "rerun_tests " ;
59-
6052 $ force = $ input ->getOption ('force ' );
6153 $ debug = $ input ->getOption ('debug ' ) ?? MftfApplicationConfig::LEVEL_DEVELOPER ; // for backward compatibility
6254 $ allowSkipped = $ input ->getOption ('allow-skipped ' );
@@ -71,7 +63,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7163 $ allowSkipped
7264 );
7365
74- $ testConfiguration = $ this ->getFailedTestList ();
66+ $ testsFailedFile = $ this ->getTestsOutputDir () . self ::FAILED_FILE ;
67+ $ testsReRunFile = $ this ->getTestsOutputDir () . "rerun_tests " ;
68+ $ testConfiguration = $ this ->getFailedTestList ($ testsFailedFile , $ testsReRunFile );
7569
7670 if ($ testConfiguration === null ) {
7771 // No failed tests found, no tests generated
@@ -98,16 +92,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9892 *
9993 * @return string
10094 */
101- private function getFailedTestList ()
95+ public function getFailedTestList ($ testsFailedFile , $ testsReRunFile )
10296 {
10397 $ failedTestDetails = ['tests ' => [], 'suites ' => []];
10498
105- if (realpath ($ this ->testsFailedFile )) {
106- $ testList = $ this ->readFailedTestFile ($ this ->testsFailedFile );
99+ $ testList = $ this ->readFailedTestFile ($ testsFailedFile );
107100
101+ if (!empty ($ testList )) {
108102 foreach ($ testList as $ test ) {
109103 if (!empty ($ test )) {
110- $ this ->writeFailedTestToFile ($ test , $ this -> testsReRunFile );
104+ $ this ->writeFailedTestToFile ($ test , $ testsReRunFile );
111105 $ testInfo = explode (DIRECTORY_SEPARATOR , $ test );
112106 $ testName = explode (": " , $ testInfo [count ($ testInfo ) - 1 ])[1 ];
113107 $ suiteName = $ testInfo [count ($ testInfo ) - 2 ];
@@ -160,9 +154,12 @@ private function sanitizeSuiteName($suiteName)
160154 * @param string $filePath
161155 * @return array|boolean
162156 */
163- private function readFailedTestFile ($ filePath )
157+ public function readFailedTestFile ($ filePath )
164158 {
165- return file ($ filePath , FILE_IGNORE_NEW_LINES );
159+ if (realpath ($ filePath )) {
160+ return file ($ filePath , FILE_IGNORE_NEW_LINES );
161+ }
162+ return "" ;
166163 }
167164
168165 /**
@@ -172,7 +169,7 @@ private function readFailedTestFile($filePath)
172169 * @param string $filePath
173170 * @return void
174171 */
175- private function writeFailedTestToFile ($ test , $ filePath )
172+ public function writeFailedTestToFile ($ test , $ filePath )
176173 {
177174 if (file_exists ($ filePath )) {
178175 if (strpos (file_get_contents ($ filePath ), $ test ) === false ) {
0 commit comments