Skip to content

Commit 9763062

Browse files
committed
Added exception throwing on test generation if project is not built #61
1 parent 08c089a commit 9763062

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
@@ -52,11 +52,32 @@ function generateTests($opts = ['config' => null, 'force' => true, 'nodes' => nu
5252
$GLOBALS['FORCE_PHP_GENERATE'] = true;
5353
}
5454

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

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

0 commit comments

Comments
 (0)