From 97630624d3b677844fc945b9730144921303e41d Mon Sep 17 00:00:00 2001 From: Vasyl Malanka Date: Fri, 23 Mar 2018 20:12:09 +0200 Subject: [PATCH] Added exception throwing on test generation if project is not built #61 --- RoboFile.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/RoboFile.php b/RoboFile.php index 0b891094b..6ea259ed3 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -52,11 +52,32 @@ function generateTests($opts = ['config' => null, 'force' => true, 'nodes' => nu $GLOBALS['FORCE_PHP_GENERATE'] = true; } - require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php'; + require 'dev' . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php'; + + if (!$this->isProjectBuilt()) { + throw new Exception('Please run vendor/bin/robo build:project and configure your environment (.env) first.'); + } + \Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance()->createAllTestFiles($opts['config'], $opts['nodes']); $this->say("Generate Tests Command Run"); } + /** + * Check if MFTF has been properly configured + * @return bool + */ + private function isProjectBuilt() + { + $actorFile = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Magento' . DIRECTORY_SEPARATOR . 'FunctionalTestingFramework' . DIRECTORY_SEPARATOR . '_generated' . DIRECTORY_SEPARATOR . 'AcceptanceTesterActions.php'; + + $login = getenv('MAGENTO_ADMIN_USERNAME'); + $password = getenv('MAGENTO_ADMIN_PASSWORD'); + $baseUrl = getenv('MAGENTO_BASE_URL'); + $backendName = getenv('MAGENTO_BACKEND_NAME'); + + return (file_exists($actorFile) && $login && $password && $baseUrl && $backendName); + } + /** * Generate a suite based on name(s) passed in as args. *