Skip to content

Deliver changes from Contribution Day #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a89255
Make possible to create and run MFTF test in framework to verify Fram…
okolesnyk Mar 22, 2018
45962be
Make possible to create and run MFTF test in framework to verify Fram…
okolesnyk Mar 23, 2018
c96c88a
Make possible to create and run MFTF test in framework to verify Fram…
okolesnyk Mar 23, 2018
08c089a
Make possible to create and run MFTF test in framework to verify Fram…
okolesnyk Mar 23, 2018
778a626
magento/magento2-functional-testing-framework#56: Add "block" type to…
sdzhepa Mar 23, 2018
9763062
Added exception throwing on test generation if project is not built #61
vasylmalanka Mar 23, 2018
fcb3090
magento/magento2-functional-testing-framework#58: Allow browser type …
StasKozar Mar 24, 2018
8c8a771
magento/magento2-functional-testing-framework#57: Debug flag exists i…
StasKozar Mar 24, 2018
44ced3f
magento/magento2-functional-testing-framework#58: Allow browser type …
StasKozar Mar 24, 2018
91ef188
magento/magento2-functional-testing-framework#57: Debug flag exists i…
StasKozar Mar 24, 2018
5f3438c
magento/magento2-functional-testing-framework#57: Debug flag exists i…
StasKozar Mar 24, 2018
af460ab
magento/magento2-functional-testing-framework#60: Build interactive c…
lenaorobei Mar 24, 2018
bdd366d
Make possible to create and run MFTF test in framework
okolesnyk Mar 26, 2018
e05e5e7
Merge branch 'develop' of github.com:magento/magento2-functional-test…
okolesnyk Mar 26, 2018
467fe43
Merge branch 'CD-develop' into mftf#56
okolesnyk Mar 28, 2018
ff2bce5
Merge branch 'CD-develop' into issue60
okolesnyk Mar 28, 2018
c06af5f
Merge branch 'CD-develop' into MFTF-58
okolesnyk Mar 28, 2018
8e7d4d8
Merge pull request #64 from sdzhepa/mftf#56
okolesnyk Mar 28, 2018
8703e00
Merge pull request #69 from lenaorobei/issue60
okolesnyk Mar 29, 2018
04fec9e
Merge pull request #66 from vasylmalanka/issue-61
okolesnyk Mar 29, 2018
e01f07e
Merge pull request #67 from StasKozar/MFTF-58
okolesnyk Mar 29, 2018
12ca5e4
MQE-904: Deliver changes from Magento Contribution Day
okolesnyk Mar 29, 2018
d1a7feb
Merge branch 'CD-develop' of github.com:magento/magento2-functional-t…
okolesnyk Mar 29, 2018
fd0e889
Merge pull request #70 from StasKozar/MFTF-57
okolesnyk Mar 29, 2018
9fff8f2
Merge branch 'develop' into CD-develop
okolesnyk Mar 29, 2018
3ef39ba
Merge branch 'develop' of github.com:magento/magento2-functional-test…
okolesnyk Mar 30, 2018
a34cbd1
MQE-904: Deliver changes from Contribution day
okolesnyk Mar 30, 2018
2109b0d
MQE-904: Deliver changes from Contribution day
okolesnyk Mar 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#Copyright © Magento, Inc. All rights reserved.
#See COPYING.txt for license details.

#*** Set the base URL for your Magento instance ***#
MAGENTO_BASE_URL=http://devdocs.magento.com/

#*** Set the Admin Username and Password for your Magento instance ***#
MAGENTO_BACKEND_NAME=admin
MAGENTO_ADMIN_USERNAME=admin
MAGENTO_ADMIN_PASSWORD=123123q

#*** Path to CLI entry point and command parameter name. Uncomment and change if folder structure differs from standard Magento installation
#MAGENTO_CLI_COMMAND_PATH=dev/tests/acceptance/utils/command.php
#MAGENTO_CLI_COMMAND_PARAMETER=command

#*** Selenium Server Protocol, Host, Port, and Path, with local defaults. Uncomment and change if not running Selenium locally.
#SELENIUM_HOST=127.0.0.1
#SELENIUM_PORT=4444
#SELENIUM_PROTOCOL=http
#SELENIUM_PATH=/wd/hub

#*** Browser for running tests, default chrome. Uncomment and change if you want to run tests on another browser (ex. firefox).
BROWSER=chrome

#*** Uncomment and set host & port if your dev environment needs different value other than MAGENTO_BASE_URL for Rest API Requests ***#
#MAGENTO_RESTAPI_SERVER_HOST=
#MAGENTO_RESTAPI_SERVER_PORT=

#*** Uncomment these properties to set up a dev environment with symlinked projects ***#
#TESTS_BP=
#FW_BP=
#TESTS_MODULE_PATH=

#*** These properties impact the modules loaded into MFTF, you can point to your own full path, or a custom set of modules located with the core set
MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_ConfigurableProductCatalogSearch
#CUSTOM_MODULE_PATHS=

#*** Bool property which allows the user to toggle debug output during test execution
#MFTF_DEBUG=
#*** End of .env ***#
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ build/*
clover.xml
coverage/
.vscode
codeception.yml
dev/tests/functional/MFTF.suite.yml
dev/tests/functional/_output
214 changes: 214 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

/** This is project's console commands configuration for Robo task runner.
*
* @codingStandardsIgnoreStart
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
use Robo\Task\Base\loadShortcuts;

/**
* Duplicate the Example configuration files used to customize the Project for customization.
*
* @return void
*/
function cloneFiles()
{
$this->_exec('cp -vn .env.example .env');
$this->_exec('cp -vf codeception.dist.yml codeception.yml');
$this->_exec('cp -vf dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR .'MFTF.suite.dist.yml dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR .'MFTF.suite.yml');
}

/**
* Duplicate the Example configuration files for the Project.
* Build the Codeception project.
*
* @return void
*/
function buildProject()
{
$this->writeln("<error>This command will be removed in MFTF v3.0.0. Please use bin/mftf build:project instead.</error>\n");
$this->cloneFiles();
$this->_exec('vendor'. DIRECTORY_SEPARATOR .'bin'. DIRECTORY_SEPARATOR .'codecept build');
}

/**
* Generate all Tests in PHP.
*
* @param array $tests
* @param array $opts
* @return void
*/
function generateTests(array $tests, $opts = ['config' => null, 'force' => true, 'nodes' => null, 'debug' => false])
{
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
$GLOBALS['GENERATE_TESTS'] = true;
if (!$this->isProjectBuilt()) {
$this->say("<info>Please run bin/mftf build:project and configure your environment (.env) first.</info>");
exit(\Robo\Result::EXITCODE_ERROR);
}
$testsObjects = [];
foreach ($tests as $test) {
$testsObjects[] = Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler::getInstance()->getObject($test);
}
if ($opts['force']) {
$GLOBALS['FORCE_PHP_GENERATE'] = true;
}
$testsReferencedInSuites = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance()->generateAllSuites($opts['config']);
\Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance(null, $testsObjects, $opts['debug'])->createAllTestFiles($opts['config'], $opts['nodes'], $testsReferencedInSuites);
$this->say("<comment>Generate Tests Command Run</comment>");
}

/**
* 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 = !empty(getenv('MAGENTO_ADMIN_USERNAME'));
$password = !empty(getenv('MAGENTO_ADMIN_PASSWORD'));
$baseUrl = !empty(getenv('MAGENTO_BASE_URL'));
$backendName = !empty(getenv('MAGENTO_BACKEND_NAME'));
$test = (file_exists($actorFile) && $login && $password && $baseUrl && $backendName);
return $test;
}

/**
* Generate a suite based on name(s) passed in as args.
*
* @param array $args
* @throws Exception
* @return void
*/
function generateSuite(array $args)
{
if (empty($args)) {
throw new Exception("Please provide suite name(s) after generate:suite command");
}

require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
$sg = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance();

foreach ($args as $arg) {
$sg->generateSuite($arg);
}
}

/**
* Run all MFTF tests.
*
* @return void
*/
function mftf()
{
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run MFTF --skip-group skip');
}

/**
* Run all Tests with the specified @group tag, excluding @group 'skip'.
*
* @param string $args
* @return void
*/
function group($args = '')
{
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --verbose --steps --skip-group skip --group')->args($args)->run();
}

/**
* Run all Functional tests located under the Directory Path provided.
*
* @param string $args
* @return void
*/
function folder($args = '')
{
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run ')->args($args)->run();
}

/**
* Run all Tests marked with the @group tag 'example'.
*
* @return void
*/
function example()
{
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --group example --skip-group skip');
}

/**
* Generate the HTML for the Allure report based on the Test XML output - Allure v1.4.X
*
* @return \Robo\Result
*/
function allure1Generate()
{
return $this->_exec('allure generate tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-results'. DIRECTORY_SEPARATOR .' -o tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
}

/**
* Generate the HTML for the Allure report based on the Test XML output - Allure v2.3.X
*
* @return \Robo\Result
*/
function allure2Generate()
{
return $this->_exec('allure generate tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-results'. DIRECTORY_SEPARATOR .' --output tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .' --clean');
}

/**
* Open the HTML Allure report - Allure v1.4.X
*
* @return void
*/
function allure1Open()
{
$this->_exec('allure report open --report-dir tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
}

/**
* Open the HTML Allure report - Allure v2.3.X
*
* @return void
*/
function allure2Open()
{
$this->_exec('allure open --port 0 tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
}

/**
* Generate and open the HTML Allure report - Allure v1.4.X
*
* @return void
*/
function allure1Report()
{
$result1 = $this->allure1Generate();

if ($result1->wasSuccessful()) {
$this->allure1Open();
}
}

/**
* Generate and open the HTML Allure report - Allure v2.3.X
*
* @return void
*/
function allure2Report()
{
$result1 = $this->allure2Generate();

if ($result1->wasSuccessful()) {
$this->allure2Open();
}
}
}
30 changes: 30 additions & 0 deletions bin/mftf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env php

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

if (PHP_SAPI !== 'cli') {
echo 'bin/mftf must be run as a CLI application';
exit(1);
}

try {
require_once __DIR__ . '/../bootstrap.php';
$application = new Symfony\Component\Console\Application();
$application->setName('Magento Functional Testing Framework CLI');
$application->setVersion('1.0.0');
$application->add(new Magento\FunctionalTestingFramework\Console\SetupEnvCommand());
$application->add(new Magento\FunctionalTestingFramework\Console\BuildProjectCommand());
$application->run();
} catch (\Exception $e) {
while ($e) {
echo $e->getMessage();
echo $e->getTraceAsString();
echo "\n\n";
$e = $e->getPrevious();
}
exit(1);
}
8 changes: 8 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

require_once 'vendor/autoload.php';
define('BP', __DIR__);
27 changes: 27 additions & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
actor: Tester
paths:
tests: dev/tests/functional
log: dev/tests/functional/_output
data: dev/tests/functional/_data
support: src/Magento/FunctionalTestingFramework
envs: etc/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
- Yandex\Allure\Adapter\AllureAdapter
config:
Yandex\Allure\Adapter\AllureAdapter:
deletePreviousResults: true
outputDirectory: allure-results
ignoredAnnotations:
- env
- zephyrId
- useCaseId
params:
- .env
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
},
"require": {
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0",
"allure-framework/allure-codeception": "~1.2.6",
"codeception/codeception": "~2.3.4",
"consolidation/robo": "^1.0.0",
"epfremme/swagger-php": "^2.0",
"flow/jsonpath": ">0.2",
"fzaninotto/faker": "^1.6",
"mustache/mustache": "~2.5"
"mustache/mustache": "~2.5",
"symfony/process": ">=2.7 <3.4",
"vlucas/phpdotenv": "^2.4"
},
"require-dev": {
"squizlabs/php_codesniffer": "1.5.3",
Expand All @@ -30,7 +34,8 @@
},
"autoload": {
"psr-4": {
"Magento\\FunctionalTestingFramework\\": "src/Magento/FunctionalTestingFramework"
"Magento\\FunctionalTestingFramework\\": "src/Magento/FunctionalTestingFramework",
"MFTF\\": "dev/tests/functional/MFTF"
}
},
"autoload-dev": {
Expand All @@ -46,5 +51,6 @@
"hooks": {
"pre-push": "bin/all-checks"
}
}
},
"bin": ["bin/mftf"]
}
Loading