Skip to content

Commit 7a89255

Browse files
committed
Make possible to create and run MFTF test in framework to verify Framework basic functionality
1 parent 2a0ec6c commit 7a89255

File tree

13 files changed

+5781
-2
lines changed

13 files changed

+5781
-2
lines changed

.env.example

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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=
6+
7+
#*** Set the Admin Username and Password for your Magento instance ***#
8+
MAGENTO_BACKEND_NAME=
9+
MAGENTO_ADMIN_USERNAME=
10+
MAGENTO_ADMIN_PASSWORD=
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+
#*** Uncomment and set host & port if your dev environment needs different value other than MAGENTO_BASE_URL for Rest API Requests ***#
23+
#MAGENTO_RESTAPI_SERVER_HOST=
24+
#MAGENTO_RESTAPI_SERVER_PORT=
25+
26+
#*** Uncomment these properties to set up a dev environment with symlinked projects ***#
27+
#TESTS_BP=
28+
#FW_BP=
29+
#TESTS_MODULE_PATH=
30+
31+
#*** 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
32+
MODULE_WHITELIST=Magento_Framework,Magento_ConfigurableProductWishlist,Magento_ConfigurableProductCatalogSearch
33+
#CUSTOM_MODULE_PATHS=
34+
35+
#*** Bool property which allows the user to toggle debug output during test execution
36+
#MFTF_DEBUG=
37+
#*** 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

RoboFile.php

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
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.suite.dist.yml dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR .'functional.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->cloneFiles();
37+
$this->_exec('vendor'. DIRECTORY_SEPARATOR .'bin'. DIRECTORY_SEPARATOR .'codecept build');
38+
}
39+
40+
/**
41+
* Generate all Tests in PHP.
42+
*
43+
* @param array $opts
44+
* @return void
45+
*/
46+
function generateTests($opts = ['config' => null, 'force' => true, 'nodes' => null])
47+
{
48+
$GLOBALS['GENERATE_TESTS'] = true;
49+
50+
if ($opts['force'])
51+
{
52+
$GLOBALS['FORCE_PHP_GENERATE'] = true;
53+
}
54+
55+
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
56+
\Magento\FunctionalTestingFramework\Util\TestGenerator::getInstance()->createAllTestFiles($opts['config'], $opts['nodes']);
57+
$this->say("Generate Tests Command Run");
58+
}
59+
60+
/**
61+
* Generate a suite based on name(s) passed in as args.
62+
*
63+
* @param array $args
64+
* @throws Exception
65+
* @return void
66+
*/
67+
function generateSuite(array $args)
68+
{
69+
if (empty($args)) {
70+
throw new Exception("Please provide suite name(s) after generate:suite command");
71+
}
72+
73+
require 'dev' . DIRECTORY_SEPARATOR . 'tests'. DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . '_bootstrap.php';
74+
$sg = \Magento\FunctionalTestingFramework\Suite\SuiteGenerator::getInstance();
75+
76+
foreach ($args as $arg) {
77+
$sg->generateSuite($arg);
78+
}
79+
}
80+
81+
/**
82+
* Run all Functional tests.
83+
*
84+
* @return void
85+
*/
86+
function functional()
87+
{
88+
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run functional --skip-group skip');
89+
}
90+
91+
/**
92+
* Run all Tests with the specified @group tag, excluding @group 'skip'.
93+
*
94+
* @param string $args
95+
* @return void
96+
*/
97+
function group($args = '')
98+
{
99+
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --verbose --steps --skip-group skip --group')->args($args)->run();
100+
}
101+
102+
/**
103+
* Run all Functional tests located under the Directory Path provided.
104+
*
105+
* @param string $args
106+
* @return void
107+
*/
108+
function folder($args = '')
109+
{
110+
$this->taskExec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run ')->args($args)->run();
111+
}
112+
113+
/**
114+
* Run all Tests marked with the @group tag 'example'.
115+
*
116+
* @return void
117+
*/
118+
function example()
119+
{
120+
$this->_exec('.' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'codecept run --group example --skip-group skip');
121+
}
122+
123+
/**
124+
* Generate the HTML for the Allure report based on the Test XML output - Allure v1.4.X
125+
*
126+
* @return \Robo\Result
127+
*/
128+
function allure1Generate()
129+
{
130+
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 .'');
131+
}
132+
133+
/**
134+
* Generate the HTML for the Allure report based on the Test XML output - Allure v2.3.X
135+
*
136+
* @return \Robo\Result
137+
*/
138+
function allure2Generate()
139+
{
140+
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');
141+
}
142+
143+
/**
144+
* Open the HTML Allure report - Allure v1.4.X
145+
*
146+
* @return void
147+
*/
148+
function allure1Open()
149+
{
150+
$this->_exec('allure report open --report-dir tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
151+
}
152+
153+
/**
154+
* Open the HTML Allure report - Allure v2.3.X
155+
*
156+
* @return void
157+
*/
158+
function allure2Open()
159+
{
160+
$this->_exec('allure open --port 0 tests'. DIRECTORY_SEPARATOR .'_output'. DIRECTORY_SEPARATOR .'allure-report'. DIRECTORY_SEPARATOR .'');
161+
}
162+
163+
/**
164+
* Generate and open the HTML Allure report - Allure v1.4.X
165+
*
166+
* @return void
167+
*/
168+
function allure1Report()
169+
{
170+
$result1 = $this->allure1Generate();
171+
172+
if ($result1->wasSuccessful()) {
173+
$this->allure1Open();
174+
}
175+
}
176+
177+
/**
178+
* Generate and open the HTML Allure report - Allure v2.3.X
179+
*
180+
* @return void
181+
*/
182+
function allure2Report()
183+
{
184+
$result1 = $this->allure2Generate();
185+
186+
if ($result1->wasSuccessful()) {
187+
$this->allure2Open();
188+
}
189+
}
190+
}

codeception.dist.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright © Magento, Inc. All rights reserved.
2+
# See COPYING.txt for license details.
3+
actor: Tester
4+
paths:
5+
tests: dev/tests/functional
6+
log: dev/tests/functional/_output
7+
data: dev/tests/functional/_data
8+
support: src/Magento/FunctionalTestingFramework
9+
envs: etc/_envs
10+
settings:
11+
bootstrap: _bootstrap.php
12+
colors: true
13+
memory_limit: 1024M
14+
extensions:
15+
enabled:
16+
- Codeception\Extension\RunFailed
17+
- Yandex\Allure\Adapter\AllureAdapter
18+
config:
19+
Yandex\Allure\Adapter\AllureAdapter:
20+
deletePreviousResults: true
21+
outputDirectory: allure-results
22+
ignoredAnnotations:
23+
- env
24+
- zephyrId
25+
- useCaseId
26+
params:
27+
- .env

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
},
1111
"require": {
1212
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0",
13+
"allure-framework/allure-codeception": "~1.2.6",
1314
"codeception/codeception": "~2.3.4",
15+
"consolidation/robo": "^1.0.0",
1416
"epfremme/swagger-php": "^2.0",
1517
"flow/jsonpath": ">0.2",
1618
"fzaninotto/faker": "^1.6",
17-
"mustache/mustache": "~2.5"
19+
"mustache/mustache": "~2.5",
20+
"symfony/process": ">=2.7 <3.4",
21+
"vlucas/phpdotenv": "^2.4"
1822
},
1923
"require-dev": {
2024
"squizlabs/php_codesniffer": "1.5.3",
@@ -30,7 +34,8 @@
3034
},
3135
"autoload": {
3236
"psr-4": {
33-
"Magento\\FunctionalTestingFramework\\": "src/Magento/FunctionalTestingFramework"
37+
"Magento\\FunctionalTestingFramework\\": "src/Magento/FunctionalTestingFramework",
38+
"MFTF\\": "dev/tests/functional/MFTF"
3439
}
3540
},
3641
"autoload-dev": {

0 commit comments

Comments
 (0)