|
20 | 20 | use Magento\FunctionalTestingFramework\Test\Util\ActionObjectExtractor; |
21 | 21 | use Magento\FunctionalTestingFramework\Test\Util\TestObjectExtractor; |
22 | 22 | use Magento\FunctionalTestingFramework\Util\Filesystem\DirSetupUtil; |
| 23 | +use Robo\Common\IO; |
| 24 | +use Symfony\Component\Console\Output\OutputInterface; |
23 | 25 |
|
24 | 26 | /** |
25 | 27 | * Class TestGenerator |
26 | 28 | * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) |
27 | 29 | */ |
28 | 30 | class TestGenerator |
29 | 31 | { |
| 32 | + use IO; |
| 33 | + |
30 | 34 | const REQUIRED_ENTITY_REFERENCE = 'createDataKey'; |
31 | 35 | const GENERATED_DIR = '_generated'; |
32 | 36 |
|
@@ -132,17 +136,22 @@ private function createCestFile($testPhp, $filename) |
132 | 136 | * |
133 | 137 | * @param string $runConfig |
134 | 138 | * @param int $nodes |
| 139 | + * @param bool $debug |
| 140 | + * @param OutputInterface|null $output |
135 | 141 | * @return void |
136 | 142 | * @throws TestReferenceException |
137 | 143 | * @throws \Exception |
138 | 144 | */ |
139 | | - public function createAllTestFiles($runConfig = null, $nodes = null) |
| 145 | + public function createAllTestFiles($runConfig = null, $nodes = null, $debug = false, $output = null) |
140 | 146 | { |
141 | 147 | DirSetupUtil::createGroupDir($this->exportDirectory); |
| 148 | + if ($output !== null) { |
| 149 | + $this->setOutput($output); |
| 150 | + } |
142 | 151 |
|
143 | 152 | // create our manifest file here |
144 | 153 | $testManifest = TestManifestFactory::makeManifest($this->exportDirectory, $runConfig); |
145 | | - $testPhpArray = $this->assembleAllTestPhp($testManifest, $nodes); |
| 154 | + $testPhpArray = $this->assembleAllTestPhp($testManifest, $nodes, $debug); |
146 | 155 |
|
147 | 156 | foreach ($testPhpArray as $testPhpFile) { |
148 | 157 | $this->createCestFile($testPhpFile[1], $testPhpFile[0]); |
@@ -189,29 +198,52 @@ private function assembleTestPhp($testObject) |
189 | 198 | * |
190 | 199 | * @param BaseTestManifest $testManifest |
191 | 200 | * @param int $nodes |
| 201 | + * @param bool $debug |
192 | 202 | * @return array |
193 | 203 | * @throws TestReferenceException |
194 | 204 | * @throws \Exception |
195 | 205 | */ |
196 | | - private function assembleAllTestPhp($testManifest, $nodes) |
| 206 | + private function assembleAllTestPhp($testManifest, $nodes, $debug = false) |
197 | 207 | { |
198 | 208 | /** @var TestObject[] $testObjects */ |
199 | 209 | $testObjects = $this->loadAllTestObjects(); |
200 | 210 | $cestPhpArray = []; |
201 | 211 |
|
202 | 212 | foreach ($testObjects as $test) { |
| 213 | + $this->debug('Start creating test: ' . $test->getCodeceptionName(), $debug); |
203 | 214 | $php = $this->assembleTestPhp($test); |
204 | 215 | $cestPhpArray[] = [$test->getCodeceptionName(), $php]; |
205 | 216 |
|
206 | 217 | //write to manifest here if config is not single run |
207 | 218 | $testManifest->addTest($test); |
| 219 | + $debugInformation = $test->getDebugInformation(); |
| 220 | + |
| 221 | + $this->debug($debugInformation, $debug); |
| 222 | + $this->debug('Finish creating test ' . $test->getCodeceptionName(), $debug); |
208 | 223 | } |
209 | 224 |
|
210 | 225 | $testManifest->generate($nodes); |
211 | 226 |
|
212 | 227 | return $cestPhpArray; |
213 | 228 | } |
214 | 229 |
|
| 230 | + /** |
| 231 | + * Output information in console when debug flag is enabled. |
| 232 | + * |
| 233 | + * @param array|string $messages |
| 234 | + * @param bool $debug |
| 235 | + * @return void |
| 236 | + */ |
| 237 | + private function debug($messages, $debug = false) |
| 238 | + { |
| 239 | + if ($debug && $messages) { |
| 240 | + $messages = (array) $messages; |
| 241 | + foreach ($messages as $message) { |
| 242 | + $this->say($message); |
| 243 | + } |
| 244 | + } |
| 245 | + } |
| 246 | + |
215 | 247 | /** |
216 | 248 | * Creates a PHP string for the necessary Allure and AcceptanceTester use statements. |
217 | 249 | * Since we don't support other dependencies at this time, this function takes no parameter. |
|
0 commit comments