Skip to content

Master #606

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 20 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ffbde82
Example added for grapValueFrom element
ajithkumar-maragathavel Jan 25, 2020
031b0a7
cache clean command added
ajithkumar-maragathavel Jan 28, 2020
bb1e732
Configuration path altered and information added
ajithkumar-maragathavel Jan 28, 2020
a2b0cdd
added missing node
ajithkumar-maragathavel Feb 2, 2020
8905616
Grammar and formatting
dobooth Feb 4, 2020
f60c044
Updated version number
dobooth Feb 4, 2020
0f305eb
Changed sentence formation
ajithkumar-maragathavel Feb 18, 2020
fd1d845
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 25, 2020
269a4e5
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 26, 2020
cb28721
Merge pull request #562 from ajithkumar-maragathavel/mftf-getting-sta…
KevinBKozan Feb 26, 2020
0c19ad4
Merge pull request #571 from ajithkumar-maragathavel/mftf-metadata
KevinBKozan Feb 26, 2020
3426237
Merge pull request #561 from ajithkumar-maragathavel/mftf-data-example
KevinBKozan Feb 26, 2020
7758075
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 26, 2020
a9f5bba
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 27, 2020
1c7b03b
MQE-2008: Filter test generation and execution by severity
KevinBKozan Feb 27, 2020
afc5551
MQE-2008: Filter test generation and execution by severity
KevinBKozan Feb 27, 2020
a6ec117
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 27, 2020
75f5224
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 27, 2020
c215ab0
MQE-2008: Filter test generation and execution by severity
okolesnyk Feb 27, 2020
f1d9f9e
Merge pull request #605 from magento/MQE-2008
okolesnyk Feb 27, 2020
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
Magento Functional Testing Framework Changelog
================================================
2.6.3
-----

### New Feature
* `--filter` option was added to `bin/mftf generate:tests` command. For more details please go to https://devdocs.magento.com/mftf/docs/commands/mftf.html#generatetests

2.6.2
-----
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magento/magento2-functional-testing-framework",
"description": "Magento2 Functional Testing Framework",
"type": "library",
"version": "2.6.2",
"version": "2.6.3",
"license": "AGPL-3.0",
"keywords": ["magento", "automation", "functional", "testing"],
"config": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<stories value="[Deprecated] MFTF DevDocs available"/>
<title value="[Deprecated] Magento Functional Testing Framework Documentation is available."/>
<description value="[Deprecated] Magento Functional Testing Framework Documentation is available."/>
<severity value="CRITICAL"/>
<severity value="MINOR"/>
<group value="mftf"/>
</annotations>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testGetSuiteObject()
->withTestActions()
->build();

$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockGroup1Test1, $mockGroup1Test2, $mockGroup2Test1)];
$mockTestData = array_merge($mockSimpleTest, $mockGroup1Test1, $mockGroup1Test2, $mockGroup2Test1);
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);

// parse and retrieve suite object with mocked data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testGenerateSuite()
->withTestActions()
->build();

$mockTestData = ['tests' => array_merge($mockSimpleTest)];
$mockTestData = array_merge($mockSimpleTest);
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);

// parse and generate suite object with mocked data
Expand Down Expand Up @@ -105,7 +105,7 @@ public function testGenerateAllSuites()
->withTestActions()
->build();

$mockTestData = ['tests' => array_merge($mockSimpleTest)];
$mockTestData = array_merge($mockSimpleTest);
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockData);

// parse and retrieve suite object with mocked data
Expand Down Expand Up @@ -172,7 +172,7 @@ public function testInvalidSuiteTestPair()
->withAnnotations(['group' => [['value' => 'group2']]])
->withTestActions()
->build();
$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockSimpleTest2)];
$mockTestData = array_merge($mockSimpleTest, $mockSimpleTest2);
$this->setMockTestAndSuiteParserOutput($mockTestData, $mockSuiteData);

// Make invalid manifest
Expand All @@ -196,7 +196,7 @@ public function testNonExistentSuiteTestPair()
->withAnnotations(['group' => [['value' => 'group1']]])
->withTestActions()
->build();
$mockTestData = ['tests' => array_merge($mockSimpleTest)];
$mockTestData = array_merge($mockSimpleTest);
$this->setMockTestAndSuiteParserOutput($mockTestData, []);

// Make invalid manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testGetTestObject()

$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
$this->setMockParserOutput(['tests' => $mockData]);
$this->setMockParserOutput($mockData);

// run object handler method
$toh = TestObjectHandler::getInstance();
Expand Down Expand Up @@ -135,7 +135,7 @@ public function testGetTestsByGroup()

$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
$this->setMockParserOutput(['tests' => array_merge($includeTest, $excludeTest)]);
$this->setMockParserOutput(array_merge($includeTest, $excludeTest));

// execute test method
$toh = TestObjectHandler::getInstance();
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testGetTestWithModuleName()
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup(['Vendor_' . $moduleExpected => $filepath]);

$this->setMockParserOutput(['tests' => $mockData]);
$this->setMockParserOutput($mockData);
// Execute Test Method
$toh = TestObjectHandler::getInstance();
$actualTestObject = $toh->getObject($testDataArrayBuilder->testName);
Expand Down Expand Up @@ -212,7 +212,7 @@ public function testGetTestObjectWithInvalidExtends()
->build();
$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
$this->setMockParserOutput(['tests' => $testOne]);
$this->setMockParserOutput($testOne);

$toh = TestObjectHandler::getInstance();

Expand Down Expand Up @@ -250,7 +250,7 @@ public function testGetAllTestObjectsWithInvalidExtends()

$resolverMock = new MockModuleResolverBuilder();
$resolverMock->setup();
$this->setMockParserOutput(['tests' => array_merge($testOne, $testTwo)]);
$this->setMockParserOutput(array_merge($testOne, $testTwo));

$toh = TestObjectHandler::getInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testGenerateExtendedTest()
->withTestReference("simpleTest")
->build();

$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockExtendedTest)];
$mockTestData = array_merge($mockSimpleTest, $mockExtendedTest);
$this->setMockTestOutput($mockTestData);

// parse and generate test object with mocked data
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testGenerateExtendedWithHooks()
->withTestReference("simpleTest")
->build();

$mockTestData = ['tests' => array_merge($mockSimpleTest, $mockExtendedTest)];
$mockTestData = array_merge($mockSimpleTest, $mockExtendedTest);
$this->setMockTestOutput($mockTestData);

// parse and generate test object with mocked data
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testExtendedTestNoParent()
->withTestReference("simpleTest")
->build();

$mockTestData = ['tests' => array_merge($mockExtendedTest)];
$mockTestData = array_merge($mockExtendedTest);
$this->setMockTestOutput($mockTestData);

// parse and generate test object with mocked data
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testExtendingExtendedTest()
->withTestReference("simpleTest")
->build();

$mockTestData = ['tests' => array_merge($mockParentTest, $mockSimpleTest, $mockExtendedTest)];
$mockTestData = array_merge($mockParentTest, $mockSimpleTest, $mockExtendedTest);
$this->setMockTestOutput($mockTestData);

$this->expectExceptionMessage("Cannot extend a test that already extends another test. Test: simpleTest");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use AspectMock\Test as AspectMock;

use Magento\FunctionalTestingFramework\Filter\FilterList;
use Magento\FunctionalTestingFramework\Test\Objects\ActionObject;
use Magento\FunctionalTestingFramework\Test\Objects\TestHookObject;
use Magento\FunctionalTestingFramework\Test\Objects\TestObject;
Expand All @@ -17,6 +18,16 @@

class TestGeneratorTest extends MagentoTestCase
{
/**
* After method functionality
*
* @return void
*/
public function tearDown()
{
AspectMock::clean();
}

/**
* Basic test to check exceptions for incorrect entities.
*
Expand Down Expand Up @@ -99,4 +110,54 @@ public function testAllowSkipped()
$this->assertContains($actionInput, $output);
$this->assertContains($beforeActionInput, $output);
}

/**
* Tests that TestGenerator createAllTestFiles correctly filters based on severity
*
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
*/
public function testFilter()
{
// Mock filters for TestGenerator
AspectMock::double(
MftfApplicationConfig::class,
['getFilterList' => new FilterList(['severity' => ["CRITICAL"]])]
);

$actionInput = 'fakeInput';
$actionObject = new ActionObject('fakeAction', 'comment', [
'userInput' => $actionInput
]);

$annotation1 = ['severity' => ['CRITICAL']];
$annotation2 = ['severity' => ['MINOR']];
$test1 = new TestObject(
"test1",
["fakeAction" => $actionObject],
$annotation1,
[],
"filename"
);
$test2 = new TestObject(
"test2",
["fakeAction" => $actionObject],
$annotation2,
[],
"filename"
);
AspectMock::double(TestGenerator::class, ['loadAllTestObjects' => ["sampleTest" => $test1, "test2" => $test2]]);

// Mock createCestFile to return name of tests that testGenerator tried to create
$generatedTests = [];
AspectMock::double(TestGenerator::class, ['createCestFile' => function ($arg1, $arg2) use (&$generatedTests) {
$generatedTests[$arg2] = true;
}]);

$testGeneratorObject = TestGenerator::getInstance("", ["sampleTest" => $test1, "test2" => $test2]);
$testGeneratorObject->createAllTestFiles(null, []);

// Ensure Test1 was Generated but not Test 2
$this->assertArrayHasKey('test1Cest', $generatedTests);
$this->assertArrayNotHasKey('test2Cest', $generatedTests);
}
}
1 change: 1 addition & 0 deletions docs/commands/mftf.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ vendor/bin/mftf generate:tests [option] [<test name>] [<test name>] [--remove]
| Option | Description|
| ---| --- |
| `--config=[<default> or <singleRun> or <parallel>]` | Creates a single manifest file with a list of all tests. The default location is `tests/functional/Magento/FunctionalTest/_generated/testManifest.txt`.<br/> You can split the list into multiple groups using `--config=parallel`; the groups will be generated in `_generated/groups/` like `_generated/groups/group1.txt, group2.txt, ...`.<br/> Available values: `default` (default), `singleRun`(same as `default`), and `parallel`.<br/> Example: `generate:tests --config=parallel`. |
| `--filter` | Option to filter tests to be generated.<br/>Template: '<filterName>:<filterValue>'.<br/>Existing filter types: severity.<br/>Existing severity values: BLOCKER, CRITICAL, MAJOR, AVERAGE, MINOR.<br/>Example: --filter=severity:CRITICAL|
| `--force` | Forces test generation, regardless of the module merge order defined in the Magento instance. Example: `generate:tests --force`. |
| `-i,--time` | Set time in minutes to determine the group size when `--config=parallel` is used. The __default value__ is `10`. Example: `generate:tests --config=parallel --time=15`|
| `--tests` | Defines the test configuration as a JSON string.|
Expand Down
10 changes: 10 additions & 0 deletions docs/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ The following example shows the usage of `grabValueFrom` in testing, where the r
<fillField selector=".functionalTestSelector" userInput="{$grabStepKey}" stepKey="fillFieldKey1"/>
```

The following is an example of the `Magento/Catalog/Test/Mftf/ActionGroup/AssertDiscountsPercentageOfProductsActionGroup.xml` test:

```xml
<grabValueFrom selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('0')}}" stepKey="grabProductTierPriceInput"/>
<assertEquals stepKey="assertProductTierPriceInput">
<expectedResult type="string">{{amount}}</expectedResult>
<actualResult type="string">$grabProductTierPriceInput</actualResult>
</assertEquals>
```

## Hard-coded data input

The data to operate against can be included as literals in a test. Hard-coded data input can be useful in assertions.
Expand Down
24 changes: 18 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<div class="bs-callout bs-callout-info" markdown="1">
[Find your MFTF version][] of the MFTF.
The latest Magento 2.3.x release supports MFTF 2.4.5.
The latest Magento 2.3.x release supports MFTF 2.5.3.
The latest Magento 2.2.x release supports MFTF 2.4.5.
</div>

## Prepare environment {#prepare-environment}
## Prepare environment {#prepare-environment}

Make sure that you have the following software installed and configured on your development environment:

Expand Down Expand Up @@ -53,11 +53,11 @@ Install the Magento application.
composer install
```

## Prepare Magento {#prepare-magento}
## Prepare Magento {#prepare-magento}

Configure the following settings in Magento as described below.

### WYSIWYG settings {#wysiwyg-settings}
### WYSIWYG settings {#wysiwyg-settings}

A Selenium web driver cannot enter data to fields with WYSIWYG.

Expand All @@ -74,6 +74,12 @@ or via command line:
bin/magento config:set cms/wysiwyg/enabled disabled
```

Clean the cache after changing the configuration values:

```bash
bin/magento cache:clean config full_page
```

<div class="bs-callout bs-callout-tip">
When you want to test the WYSIWYG functionality, re-enable WYSIWYG in your test suite.
</div>
Expand All @@ -97,15 +103,21 @@ bin/magento config:set admin/security/admin_account_sharing 1
bin/magento config:set admin/security/use_form_key 0
```

Clean the cache after changing the configuration values:

```bash
bin/magento cache:clean config full_page
```

### Webserver configuration {#web-server-configuration}

The MFTF does not support executing CLI commands if your web server points to `<MAGE_ROOT_DIR>/pub` directory as recommended in the [Installation Guide][Installation Guide docroot]. For the MFTF to execute the CLI commands, the web server must point to the Magento root directory.

### Nginx settings {#nginx-settings}

If Nginx Web server is used on your development environment then **Use Web Server Rewrites** setting in **Stores** > Settings > **Configuration** > **Web** > **Search Engine Optimization** must be set to **Yes**.
If the Nginx Web server is used on your development environment, then **Use Web Server Rewrites** setting in **Stores** > Settings > **Configuration** > **General** > **Web** > **Search Engine Optimization** must be set to **Yes**.

To be able to run Magento command line commands in tests add the following location block to Nginx configuration file:
To be able to run Magento command line commands in tests, add the following location block to the Nginx configuration file in the Magento root directory:

```conf
location ~* ^/dev/tests/acceptance/utils($|/) {
Expand Down
1 change: 1 addition & 0 deletions docs/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following diagram demonstrates the XML structure of a metadata file:
</array>
</object>
</operation>
</operations>
```

## Principles {#principles}
Expand Down
Loading