@@ -52,6 +52,13 @@ class TestGenerator
52
52
*/
53
53
private $ tests ;
54
54
55
+ /**
56
+ * Symfony console output interface.
57
+ *
58
+ * @var \Symfony\Component\Console\Output\ConsoleOutput
59
+ */
60
+ private $ consoleOutput ;
61
+
55
62
/**
56
63
* TestGenerator constructor.
57
64
*
@@ -69,6 +76,7 @@ private function __construct($exportDir, $tests)
69
76
. DIRECTORY_SEPARATOR
70
77
. $ exportDir ;
71
78
$ this ->tests = $ tests ;
79
+ $ this ->consoleOutput = new \Symfony \Component \Console \Output \ConsoleOutput ();
72
80
}
73
81
74
82
/**
@@ -135,11 +143,12 @@ private function createCestFile($testPhp, $filename)
135
143
*
136
144
* @param string $runConfig
137
145
* @param int $nodes
146
+ * @param bool $debug
138
147
* @return void
139
148
* @throws TestReferenceException
140
149
* @throws \Exception
141
150
*/
142
- public function createAllTestFiles ($ runConfig = null , $ nodes = null )
151
+ public function createAllTestFiles ($ runConfig = null , $ nodes = null , $ debug = false )
143
152
{
144
153
DirSetupUtil::createGroupDir ($ this ->exportDirectory );
145
154
@@ -149,7 +158,7 @@ public function createAllTestFiles($runConfig = null, $nodes = null)
149
158
$ this ->exportDirectory ,
150
159
$ runConfig
151
160
);
152
- $ testPhpArray = $ this ->assembleAllTestPhp ($ testManifest , $ nodes );
161
+ $ testPhpArray = $ this ->assembleAllTestPhp ($ testManifest , $ nodes, $ debug );
153
162
154
163
foreach ($ testPhpArray as $ testPhpFile ) {
155
164
$ this ->createCestFile ($ testPhpFile [1 ], $ testPhpFile [0 ]);
@@ -196,29 +205,52 @@ private function assembleTestPhp($testObject)
196
205
*
197
206
* @param BaseTestManifest $testManifest
198
207
* @param int $nodes
208
+ * @param bool $debug
199
209
* @return array
200
210
* @throws TestReferenceException
201
211
* @throws \Exception
202
212
*/
203
- private function assembleAllTestPhp ($ testManifest , $ nodes )
213
+ private function assembleAllTestPhp ($ testManifest , $ nodes, $ debug = false )
204
214
{
205
215
/** @var TestObject[] $testObjects */
206
216
$ testObjects = $ this ->loadAllTestObjects ();
207
217
$ cestPhpArray = [];
208
218
209
219
foreach ($ testObjects as $ test ) {
220
+ $ this ->debug ('Start creating test: ' . $ test ->getCodeceptionName (), $ debug );
210
221
$ php = $ this ->assembleTestPhp ($ test );
211
222
$ cestPhpArray [] = [$ test ->getCodeceptionName (), $ php ];
212
223
213
224
//write to manifest here if config is not single run
214
225
$ testManifest ->addTest ($ test );
226
+ $ debugInformation = $ test ->getDebugInformation ();
227
+
228
+ $ this ->debug ($ debugInformation , $ debug );
229
+ $ this ->debug ('Finish creating test ' . $ test ->getCodeceptionName () . PHP_EOL , $ debug );
215
230
}
216
231
217
232
$ testManifest ->generate ($ nodes );
218
233
219
234
return $ cestPhpArray ;
220
235
}
221
236
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
+
222
254
/**
223
255
* Creates a PHP string for the necessary Allure and AcceptanceTester use statements.
224
256
* Since we don't support other dependencies at this time, this function takes no parameter.
0 commit comments