@@ -52,6 +52,13 @@ class TestGenerator
5252 */
5353 private $ tests ;
5454
55+ /**
56+ * Symfony console output interface.
57+ *
58+ * @var \Symfony\Component\Console\Output\ConsoleOutput
59+ */
60+ private $ consoleOutput ;
61+
5562 /**
5663 * TestGenerator constructor.
5764 *
@@ -69,6 +76,7 @@ private function __construct($exportDir, $tests)
6976 . DIRECTORY_SEPARATOR
7077 . $ exportDir ;
7178 $ this ->tests = $ tests ;
79+ $ this ->consoleOutput = new \Symfony \Component \Console \Output \ConsoleOutput ();
7280 }
7381
7482 /**
@@ -135,11 +143,12 @@ private function createCestFile($testPhp, $filename)
135143 *
136144 * @param string $runConfig
137145 * @param int $nodes
146+ * @param bool $debug
138147 * @return void
139148 * @throws TestReferenceException
140149 * @throws \Exception
141150 */
142- public function createAllTestFiles ($ runConfig = null , $ nodes = null )
151+ public function createAllTestFiles ($ runConfig = null , $ nodes = null , $ debug = false )
143152 {
144153 DirSetupUtil::createGroupDir ($ this ->exportDirectory );
145154
@@ -149,7 +158,7 @@ public function createAllTestFiles($runConfig = null, $nodes = null)
149158 $ this ->exportDirectory ,
150159 $ runConfig
151160 );
152- $ testPhpArray = $ this ->assembleAllTestPhp ($ testManifest , $ nodes );
161+ $ testPhpArray = $ this ->assembleAllTestPhp ($ testManifest , $ nodes, $ debug );
153162
154163 foreach ($ testPhpArray as $ testPhpFile ) {
155164 $ this ->createCestFile ($ testPhpFile [1 ], $ testPhpFile [0 ]);
@@ -196,29 +205,52 @@ private function assembleTestPhp($testObject)
196205 *
197206 * @param BaseTestManifest $testManifest
198207 * @param int $nodes
208+ * @param bool $debug
199209 * @return array
200210 * @throws TestReferenceException
201211 * @throws \Exception
202212 */
203- private function assembleAllTestPhp ($ testManifest , $ nodes )
213+ private function assembleAllTestPhp ($ testManifest , $ nodes, $ debug = false )
204214 {
205215 /** @var TestObject[] $testObjects */
206216 $ testObjects = $ this ->loadAllTestObjects ();
207217 $ cestPhpArray = [];
208218
209219 foreach ($ testObjects as $ test ) {
220+ $ this ->debug ('Start creating test: ' . $ test ->getCodeceptionName (), $ debug );
210221 $ php = $ this ->assembleTestPhp ($ test );
211222 $ cestPhpArray [] = [$ test ->getCodeceptionName (), $ php ];
212223
213224 //write to manifest here if config is not single run
214225 $ testManifest ->addTest ($ test );
226+ $ debugInformation = $ test ->getDebugInformation ();
227+
228+ $ this ->debug ($ debugInformation , $ debug );
229+ $ this ->debug ('Finish creating test ' . $ test ->getCodeceptionName () . PHP_EOL , $ debug );
215230 }
216231
217232 $ testManifest ->generate ($ nodes );
218233
219234 return $ cestPhpArray ;
220235 }
221236
237+ /**
238+ * Output information in console when debug flag is enabled.
239+ *
240+ * @param array|string $messages
241+ * @param bool $debug
242+ * @return void
243+ */
244+ private function debug ($ messages , $ debug = false )
245+ {
246+ if ($ debug && $ messages ) {
247+ $ messages = (array ) $ messages ;
248+ foreach ($ messages as $ message ) {
249+ $ this ->consoleOutput ->writeln ($ message );
250+ }
251+ }
252+ }
253+
222254 /**
223255 * Creates a PHP string for the necessary Allure and AcceptanceTester use statements.
224256 * Since we don't support other dependencies at this time, this function takes no parameter.
0 commit comments