Skip to content

Commit 04fec9e

Browse files
authored
Merge pull request #66 from vasylmalanka/issue-61
#61: Validate build:project was run before attempting to generate tests
2 parents 8703e00 + 9763062 commit 04fec9e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

RoboFile.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,32 @@ function generateTests($opts = ['config' => null, 'force' => true, 'nodes' => nu
5353
$GLOBALS['FORCE_PHP_GENERATE'] = true;
5454
}
5555

56-
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
56+
require 'dev' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
57+
58+
if (!$this->isProjectBuilt()) {
59+
throw new Exception('Please run vendor/bin/robo build:project and configure your environment (.env) first.');
60+
}
61+
5762
\Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance()->createAllTestFiles($opts['config'], $opts['nodes']);
5863
$this->say("Generate Tests Command Run");
5964
}
6065

66+
/**
67+
* Check if MFTF has been properly configured
68+
* @return bool
69+
*/
70+
private function isProjectBuilt()
71+
{
72+
$actorFile = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Magento' . DIRECTORY_SEPARATOR . 'FunctionalTestingFramework' . DIRECTORY_SEPARATOR . '_generated' . DIRECTORY_SEPARATOR . 'AcceptanceTesterActions.php';
73+
74+
$login = getenv('MAGENTO_ADMIN_USERNAME');
75+
$password = getenv('MAGENTO_ADMIN_PASSWORD');
76+
$baseUrl = getenv('MAGENTO_BASE_URL');
77+
$backendName = getenv('MAGENTO_BACKEND_NAME');
78+
79+
return (file_exists($actorFile) && $login && $password && $baseUrl && $backendName);
80+
}
81+
6182
/**
6283
* Generate a suite based on name(s) passed in as args.
6384
*

0 commit comments

Comments
 (0)