Skip to content

Commit 4177204

Browse files
authored
Merge pull request #116 from magento/develop
MQE-953: Merge the release branch to master
2 parents 10d547a + fb1e4b7 commit 4177204

File tree

117 files changed

+9233
-568
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+9233
-568
lines changed

.env.example

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#Copyright © Magento, Inc. All rights reserved.
2+
#See COPYING.txt for license details.
3+
4+
#*** Set the base URL for your Magento instance ***#
5+
MAGENTO_BASE_URL=http://devdocs.magento.com/
6+
7+
#*** Set the Admin Username and Password for your Magento instance ***#
8+
MAGENTO_BACKEND_NAME=admin
9+
MAGENTO_ADMIN_USERNAME=admin
10+
MAGENTO_ADMIN_PASSWORD=123123q
11+
12+
#*** Path to CLI entry point and command parameter name. Uncomment and change if folder structure differs from standard Magento installation
13+
#MAGENTO_CLI_COMMAND_PATH=dev/tests/acceptance/utils/command.php
14+
#MAGENTO_CLI_COMMAND_PARAMETER=command
15+
16+
#*** Selenium Server Protocol, Host, Port, and Path, with local defaults. Uncomment and change if not running Selenium locally.
17+
#SELENIUM_HOST=127.0.0.1
18+
#SELENIUM_PORT=4444
19+
#SELENIUM_PROTOCOL=http
20+
#SELENIUM_PATH=/wd/hub
21+
22+
#*** Browser for running tests, default chrome. Uncomment and change if you want to run tests on another browser (ex. firefox).
23+
BROWSER=chrome
24+
25+
#*** Uncomment and set host & port if your dev environment needs different value other than MAGENTO_BASE_URL for Rest API Requests ***#
26+
#MAGENTO_RESTAPI_SERVER_HOST=
27+
#MAGENTO_RESTAPI_SERVER_PORT=
28+
29+
#*** Uncomment these properties to set up a dev environment with symlinked projects ***#
30+
#TESTS_BP=
31+
#FW_BP=
32+
#TESTS_MODULE_PATH=
33+
34+
#*** 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
35+
MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_ConfigurableProductCatalogSearch
36+
#CUSTOM_MODULE_PATHS=
37+
38+
#*** Bool property which allows the user to toggle debug output during test execution
39+
#MFTF_DEBUG=
40+
#*** End of .env ***#

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ build/*
1111
clover.xml
1212
coverage/
1313
.vscode
14+
codeception.yml
15+
dev/tests/functional/MFTF.suite.yml
16+
dev/tests/functional/_output

CHANGELOG.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
Magento Functional Testing Framework Changelog
22
================================================
33

4+
2.2.0
5+
-----
6+
### Enhancements
7+
* Traceability
8+
* Javascript errors are now logged and reported in test output.
9+
* Test failures are no longer overwritten by failures in an `<after>` hook.
10+
* Tests will no longer execute an `<after>` hook twice if a failure triggered in the `<after>` hook.
11+
* Tests marked with `<group value="skip">` will now appear in generated Allure reports.
12+
* Along with the above, the `robo group` command no longer omits the `skip` group (skipped tests are picked up but not fully executed).
13+
* Modularity
14+
* MFTF no longer relies on relative pathing to determine its path to tests or Magento (favoring composer information if available).
15+
* Tests and test materials are now read in from Magento modules as well as extensions in addition to `dev/tests/acceptance`.
16+
* See DevDocs `Getting Started` for details on expected paths and merge order.
17+
* Customizability
18+
* Creation of Suites is now supported
19+
* `<suite>` can include tests via `name`, module, or `<group>` tags.
20+
* Consolidation of preconditions can be achieved via use of `<before/after>` tags in a `<suite>`
21+
* All normal test actions are supported
22+
* Data returned from actions is not available for reference in subsequent tests (`createData` or `grab` actions).
23+
* `robo generate:tests` generates all suites and tests, and can be given a JSON configuration to generate specific test/suites.
24+
* See MFTF Devdocs "Suite" page for more details.
25+
* `<deleteData>` may now be called against a `url` instead of a stepKey reference.
26+
* `<dragAndDrop>` may now be given an additional `x/y` offset.
27+
* `<executeJS>` now returns a variable based on what the executed script returns.
28+
* Added `<element>` `type="block"`.
29+
* `<page>` elements may now be blank (contain no child sections).
30+
* Maintainability
31+
* `robo generate:tests --config parallel` now accepts a `--lines` argument, for grouping and sorting based on test length.
32+
* `robo generate:tests` now checks for:
33+
* Duplicate step keys within an `actionGroup`.
34+
* Ambiguous or invalid `stepKey` references (in merge files).
35+
* `robo generate:tests` now suppresses warnings by default. The command now accepts a `--verbose` flag to show full output including warnings.
36+
37+
### Fixes
38+
* Exception message for the `<conditionalClick>` action now correctly references the `selector` given.
39+
* Usage of multiple parameterized elements in a `selector` now correctly resolves all element references.
40+
* Usage of multiple uniqueness references on the same entity now generate correctly.
41+
* Persisted entity references are correctly interpolated with `<page>` url of `type="admin"`.
42+
* Metadata that contains 2 or more params in its `url` now correctly resolve parameters.
43+
* Arguments can now be passed to `x` and `y` attributes in `actionGroup`.
44+
* Arguments can now be passed to nested `<assert*>` action elements.
45+
* The `<seeInField>` action can now be used to assert against empty strings.
46+
* Empty `<data>` elements within an `<entity>` now generate correctly.
47+
* Mapping of the `<magentoCLI>` to the custom command has been fixed.
48+
49+
### GitHub Issues/Pull requests:
50+
* [#89](https://github.com/magento/magento2-functional-testing-framework/pull/89) -- Add ability to use array entities as arguments.
51+
* [#68](https://github.com/magento/magento2-functional-testing-framework/issues/68) -- Excessive double quotes are being generated in WaitForElementChange method arguments (fixed in [#103](https://github.com/magento/magento2-functional-testing-framework/pull/103))
52+
* [#31](https://github.com/magento/magento2-functional-testing-framework/issues/31) -- Can't run tests without a store having "default" store code (fixed in [#86](https://github.com/magento/magento2-functional-testing-framework/pull/86))
53+
454
2.1.2
555
-----
656
### Enhancements

RoboFile.php

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/** This is project's console commands configuration for Robo task runner.
8+
*
9+
* @codingStandardsIgnoreStart
10+
* @see http://robo.li/
11+
*/
12+
class RoboFile extends \Robo\Tasks
13+
{
14+
use Robo\Task\Base\loadShortcuts;
15+
16+
/**
17+
* Duplicate the Example configuration files used to customize the Project for customization.
18+
*
19+
* @return void
20+
*/
21+
function cloneFiles()
22+
{
23+
$this->_exec('cp -vn .env.example .env');
24+
$this->_exec('cp -vf codeception.dist.yml codeception.yml');
25+
$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');
26+
}
27+
28+
/**
29+
* Duplicate the Example configuration files for the Project.
30+
* Build the Codeception project.
31+
*
32+
* @return void
33+
*/
34+
function buildProject()
35+
{
36+
$this->writeln("<error>This command will be removed in MFTF v3.0.0. Please use bin/mftf build:project instead.</error>\n");
37+
$this->cloneFiles();
38+
$this->_exec('vendor'. DIRECTORY_SEPARATOR .'bin'. DIRECTORY_SEPARATOR .'codecept build');
39+
}
40+
41+
/**
42+
* Generate all Tests in PHP.
43+
*
44+
* @param array $tests
45+
* @param array $opts
46+
* @return void
47+
*/
48+
function generateTests(array $tests, $opts = ['config' => null, 'force' => true, 'nodes' => null, 'debug' => false])
49+
{
50+
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
51+
$GLOBALS['GENERATE_TESTS'] = true;
52+
if (!$this->isProjectBuilt()) {
53+
$this->say("<info>Please run bin/mftf build:project and configure your environment (.env) first.</info>");
54+
exit(\Robo\Result::EXITCODE_ERROR);
55+
}
56+
$testsObjects = [];
57+
foreach ($tests as $test) {
58+
$testsObjects[] = Magento\FunctionalTestingFramework\Test\Handlers\TestObjectHandler::getInstance()->getObject($test);
59+
}
60+
if ($opts['force']) {
61+
$GLOBALS['FORCE_PHP_GENERATE'] = true;
62+
}
63+
$testsReferencedInSuites = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance()->generateAllSuites($opts['config']);
64+
\Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance(null, $testsObjects, $opts['debug'])->createAllTestFiles($opts['config'], $opts['nodes'], $testsReferencedInSuites);
65+
$this->say("<comment>Generate Tests Command Run</comment>");
66+
}
67+
68+
/**
69+
* Check if MFTF has been properly configured
70+
* @return bool
71+
*/
72+
private function isProjectBuilt()
73+
{
74+
$actorFile = __DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Magento' . DIRECTORY_SEPARATOR . 'FunctionalTestingFramework' . DIRECTORY_SEPARATOR . '_generated' . DIRECTORY_SEPARATOR . 'AcceptanceTesterActions.php';
75+
76+
$login = !empty(getenv('MAGENTO_ADMIN_USERNAME'));
77+
$password = !empty(getenv('MAGENTO_ADMIN_PASSWORD'));
78+
$baseUrl = !empty(getenv('MAGENTO_BASE_URL'));
79+
$backendName = !empty(getenv('MAGENTO_BACKEND_NAME'));
80+
$test = (file_exists($actorFile) && $login && $password && $baseUrl && $backendName);
81+
return $test;
82+
}
83+
84+
/**
85+
* Generate a suite based on name(s) passed in as args.
86+
*
87+
* @param array $args
88+
* @throws Exception
89+
* @return void
90+
*/
91+
function generateSuite(array $args)
92+
{
93+
if (empty($args)) {
94+
throw new Exception("Please provide suite name(s) after generate:suite command");
95+
}
96+
97+
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
98+
$sg = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance();
99+
100+
foreach ($args as $arg) {
101+
$sg->generateSuite($arg);
102+
}
103+
}
104+
105+
/**
106+
* Run all MFTF tests.
107+
*
108+
* @return void
109+
*/
110+
function mftf()
111+
{
112+
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run MFTF --skip-group skip');
113+
}
114+
115+
/**
116+
* Run all Tests with the specified @group tag, excluding @group 'skip'.
117+
*
118+
* @param string $args
119+
* @return void
120+
*/
121+
function group($args = '')
122+
{
123+
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --verbose --steps --skip-group skip --group')->args($args)->run();
124+
}
125+
126+
/**
127+
* Run all Functional tests located under the Directory Path provided.
128+
*
129+
* @param string $args
130+
* @return void
131+
*/
132+
function folder($args = '')
133+
{
134+
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run ')->args($args)->run();
135+
}
136+
137+
/**
138+
* Run all Tests marked with the @group tag 'example'.
139+
*
140+
* @return void
141+
*/
142+
function example()
143+
{
144+
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --group example --skip-group skip');
145+
}
146+
147+
/**
148+
* Generate the HTML for the Allure report based on the Test XML output - Allure v1.4.X
149+
*
150+
* @return \Robo\Result
151+
*/
152+
function allure1Generate()
153+
{
154+
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 .'');
155+
}
156+
157+
/**
158+
* Generate the HTML for the Allure report based on the Test XML output - Allure v2.3.X
159+
*
160+
* @return \Robo\Result
161+
*/
162+
function allure2Generate()
163+
{
164+
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');
165+
}
166+
167+
/**
168+
* Open the HTML Allure report - Allure v1.4.X
169+
*
170+
* @return void
171+
*/
172+
function allure1Open()
173+
{
174+
$this->_exec('allure report open --report-dir tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
175+
}
176+
177+
/**
178+
* Open the HTML Allure report - Allure v2.3.X
179+
*
180+
* @return void
181+
*/
182+
function allure2Open()
183+
{
184+
$this->_exec('allure open --port 0 tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
185+
}
186+
187+
/**
188+
* Generate and open the HTML Allure report - Allure v1.4.X
189+
*
190+
* @return void
191+
*/
192+
function allure1Report()
193+
{
194+
$result1 = $this->allure1Generate();
195+
196+
if ($result1->wasSuccessful()) {
197+
$this->allure1Open();
198+
}
199+
}
200+
201+
/**
202+
* Generate and open the HTML Allure report - Allure v2.3.X
203+
*
204+
* @return void
205+
*/
206+
function allure2Report()
207+
{
208+
$result1 = $this->allure2Generate();
209+
210+
if ($result1->wasSuccessful()) {
211+
$this->allure2Open();
212+
}
213+
}
214+
}

bin/mftf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env php
2+
3+
<?php
4+
/**
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
9+
if (PHP_SAPI !== 'cli') {
10+
echo 'bin/mftf must be run as a CLI application';
11+
exit(1);
12+
}
13+
14+
try {
15+
require_once __DIR__ . '/../bootstrap.php';
16+
$application = new Symfony\Component\Console\Application();
17+
$application->setName('Magento Functional Testing Framework CLI');
18+
$application->setVersion('1.0.0');
19+
$application->add(new Magento\FunctionalTestingFramework\Console\SetupEnvCommand());
20+
$application->add(new Magento\FunctionalTestingFramework\Console\BuildProjectCommand());
21+
$application->run();
22+
} catch (\Exception $e) {
23+
while ($e) {
24+
echo $e->getMessage();
25+
echo $e->getTraceAsString();
26+
echo "\n\n";
27+
$e = $e->getPrevious();
28+
}
29+
exit(1);
30+
}

bin/static-checks

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88
echo "==============================="
99
echo " CODE SNIFFER"
1010
echo "==============================="
11-
vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento
11+
vendor/bin/phpcs ./src --standard=./dev/tests/static/Magento --ignore=src/Magento/FunctionalTestingFramework/Group,src/Magento/FunctionalTestingFramework/AcceptanceTester.php
1212
vendor/bin/phpcs ./dev/tests/unit --standard=./dev/tests/static/Magento
1313
vendor/bin/phpcs ./dev/tests/verification --standard=./dev/tests/static/Magento --ignore=dev/tests/verification/_generated
1414
echo ""
@@ -22,7 +22,7 @@ echo ""
2222
echo "==============================="
2323
echo " MESS DETECTOR"
2424
echo "==============================="
25-
vendor/bin/phpmd ./src text /dev/tests/static/Magento/CodeMessDetector/ruleset.xml --exclude _generated
25+
vendor/bin/phpmd ./src text /dev/tests/static/Magento/CodeMessDetector/ruleset.xml --exclude _generated,src/Magento/FunctionalTestingFramework/Group,src/Magento/FunctionalTestingFramework/AcceptanceTester.php
2626
echo ""
2727

2828
echo "==============================="

bin/static-checks.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
@echo off
77
@echo ===============================PHP CODE SNIFFER REPORT===============================
8-
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento
8+
call vendor\bin\phpcs .\src --standard=.\dev\tests\static\Magento --ignore=src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
99
call vendor\bin\phpcs .\dev\tests\unit --standard=.\dev\tests\static\Magento
1010
call vendor\bin\phpcs .\dev\tests\verification --standard=.\dev\tests\static\Magento --ignore=dev\tests\verification\_generated
1111

1212
@echo ===============================COPY PASTE DETECTOR REPORT===============================
1313
call vendor\bin\phpcpd .\src
1414

1515
@echo "===============================PHP MESS DETECTOR REPORT===============================
16-
vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated
16+
vendor\bin\phpmd .\src text \dev\tests\static\Magento\CodeMessDetector\ruleset.xml --exclude _generated,src\Magento\FunctionalTestingFramework\Group,src\Magento\FunctionalTestingFramework\AcceptanceTester.php
1717

1818
@echo ===============================MAGENTO COPYRIGHT REPORT===============================
1919
echo msgbox "INFO:Copyright check currently not run as part of .bat implementation" > "%temp%\popup.vbs"

bootstrap.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
require_once 'vendor/autoload.php';
8+
define('BP', __DIR__);

0 commit comments

Comments
 (0)