Skip to content

Commit db889ea

Browse files
committed
Merge pull request magento#116 from Magento/pubsMTA2873
Pubs mta2873
2 parents 965b039 + ed4ad61 commit db889ea

File tree

3 files changed

+110
-5
lines changed

3 files changed

+110
-5
lines changed

guides/v2.0/mtf/mtf_entities/mtf_dataset.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ github_link: mtf/mtf_entities/mtf_dataset.md
1414
{:toc}
1515

1616
##Data set overview {#overview}
17+
1718
Data set contains data used by a [test case] and [constraints].
1819
A data set can have several variations.
1920
Each variation has constraints that are called at the end of the test flow.
@@ -362,6 +363,7 @@ To add a new variation using merging, you should simply use the name of a [test
362363
Variations `DeleteVideoFromPCFTestVariation1` and `DeleteVideoFromPCFTestVariation2` will be used by the `Magento\Catalog\Test\TestCase\Product\UpdateSimpleProductEntityTest` class during the test run.
363364

364365
### Extend a variation with data {#extend_variation}
366+
365367
If you want to extend variation in another module using merging, you should use a [test case][] name that you want to merge with and a variation name that you want to extend.
366368

367369
For example, see how in `Magento/Catalog/Test/TestCase/Product/ValidateOrderOfProductTypeTest.xml`
@@ -375,6 +377,20 @@ For example, see how in `Magento/Catalog/Test/TestCase/Product/ValidateOrderOfPr
375377
{%highlight xml%}
376378
{%remote_markdown https://raw.githubusercontent.com/magento/magento2/develop/dev/tests/functional/tests/app/Magento/Bundle/Test/TestCase/ValidateOrderOfProductTypeTest.xml%}
377379
{%endhighlight xml%}
380+
381+
### Replace a variation {#replace_variation}
382+
383+
You can replace one variation with another by using a `replace` attribute of the `variation` node:
384+
385+
{%highlight xml%}
386+
387+
<variation name="CreateSuperNewCustomerBackendEntityTestVariation1" replace="CreateCustomerBackendEntityTestVariation1" summary="Variation that replaces default CreateCustomerBackendEntityTestVariation1">
388+
389+
{%endhighlight xml%}
390+
391+
After a merge of a data set with the variation that is mentioned, a test will use `CreateSuperNewCustomerBackendEntityTestVariation1` instead of `CreateSuperNewCustomerBackendEntityTestVariation1`.
392+
393+
<!-- LINK DEFINITIONS -->
378394

379395
[constraints]: {{site.gdeurl}}mtf/mtf_entities/mtf_constraint.html
380396
[constraint]: {{site.gdeurl}}mtf/mtf_entities/mtf_constraint.html
@@ -385,4 +401,6 @@ For example, see how in `Magento/Catalog/Test/TestCase/Product/ValidateOrderOfPr
385401
[test case]: {{site.gdeurl}}mtf/mtf_entities/mtf_testcase.html
386402
[fixture field from its repository]: {{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html#mtf_fixture_repositoy
387403

404+
<!-- ABBREVIATIONS -->
405+
388406
*[MTF]: Magento Testing Framework

guides/v2.0/mtf/mtf_entities/mtf_fixture-repo.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,82 @@ To run the generator, enter the following command in your terminal:
435435

436436
The preceding is an example of repository merging. Using the approach from the example you can merge repositories for any other fixture, not `Config` only.
437437

438+
### Data set replacement {#dataset-replacement}
439+
440+
You can modify your data set without changing the name of the data set. Simply use a `replace` attribute. For example,
441+
442+
{%highlight xml%}
443+
444+
<dataset name="customer_new_default" replace="default">
445+
446+
{%endhighlight%}
447+
448+
This node means that `customer_new_default` data set replaces `default` data set.
449+
450+
Let's see a use case example. Assume that the Customer fixture in the Magento_Customer module has a repository with the `default` data set:
451+
452+
{%highlight xml%}
453+
454+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
455+
<repository class="Magento\Customer\Test\Repository\Customer">
456+
<dataset name="default">
457+
<field name="firstname" xsi:type="string">John</field>
458+
<field name="lastname" xsi:type="string">Doe</field>
459+
<field name="group_id" xsi:type="array">
460+
<item name="dataset" xsi:type="string">General</item>
461+
</field>
462+
<field name="email" xsi:type="string">JohnDoe_%isolation%@example.com</field>
463+
<field name="password" xsi:type="string">123123q</field>
464+
<field name="password_confirmation" xsi:type="string">123123q</field>
465+
</dataset>
466+
</repository>
467+
</config>
468+
469+
{%endhighlight%}
470+
471+
Later you installed a new module Magento_CustomerNew module that changed Customer fixture. You don't want to change the `default` data set name in the test. Instead, you can simply replace the `default` data set, without changing the name:
472+
473+
{%highlight xml%}
474+
475+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
476+
<repository class="Magento\Customer\Test\Repository\Customer">
477+
<dataset name="customer_new_default" replace="default">
478+
<field name="firstname" xsi:type="string">John</field>
479+
<field name="lastname" xsi:type="string">Doe</field>
480+
<field name="email" xsi:type="string">JohnDoe_%isolation%@example.com</field>
481+
<field name="new_field" xsi:type="string">Some value</field>
482+
<field name="password" xsi:type="string">123123q</field>
483+
<field name="password_confirmation" xsi:type="string">123123q</field>
484+
</dataset>
485+
</repository>
486+
</config>
487+
488+
{%endhighlight%}
489+
490+
After the repository generation
491+
492+
php <magento2>/dev/tests/functional/utils/generate/repository.php)
493+
494+
you have the following code in the Customer repository (`<magento2>/dev/tests/functional/generated/Magento/Customer/Test/Repository/Customer.php`):
495+
496+
{%highlight php startinline=1%}
497+
498+
$this->_data['default'] = [
499+
'firstname' => 'John',
500+
'lastname' => 'Doe',
501+
'email' => 'JohnDoe_%isolation%@example.com',
502+
'new_field' => 'Some value',
503+
'password' => '123123q',
504+
'password_confirmation' => '123123q',
505+
];
506+
507+
{%endhighlight%}
508+
509+
As you can see, a repository with the name `default` contains data from the `customer_new_default` repository.
510+
438511
## Credentials and `%isolation%` in repository {#mtf_repository_credent_iso}
439512

440-
Credentials are stored in XML file specified in `phpunit.xml`.
513+
Credentials are stored in an `*.xml` file that is specified in `phpunit.xml`.
441514

442515
You can find a template for credentials in <a href="https://github.com/magento/magento2/blob/master/dev/tests/functional/credentials.xml.dist"><code>&lt;magento2&gt;/dev/tests/functional/credentials.xml.dist</code></a>.
443516

guides/v2.0/mtf/mtf_quickstart/mtf_quickstart_environmemt.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ redirect_from: /guides/v1.0/mtf/mtf_quickstart/mtf_quickstart_environmemt.html
1515

1616
### Run the Selenium Server {#mtf_quickstart_env_selenium}
1717
The Selenium Server will drive a browser to execute your tests.
18-
You can download the Selenium Server from [Selenium project website](http://www.seleniumhq.org/download/).
18+
You can download the Selenium Server from [Selenium project website][].
1919

2020
<div class="bs-callout bs-callout-warning">
2121
    <p>Install <a href="https://help.ubuntu.com/community/Java">Java</a> to work with Selenium.</p>
@@ -28,21 +28,23 @@ Enter in terminal:
2828

2929
java -jar <path_to_selenium_directory>/selenium-server.jar
3030

31-
### Run tests on non default browser {#mtf_quickstart_env_selenium-non-def}
31+
### Run tests on non-default browser {#mtf_quickstart_env_selenium-non-def}
3232

3333
If the Selenium Server does not work directly with your browser, find the corresponding [WebDriver][].
3434

35-
In `config.xml` <a href="{{site.gdeurl}}mtf/mtf_quickstart/mtf_quickstart_config.html#mtf_quickstart_config_configxml_browser"> set browser that MTF will use for tests</a>.
35+
In `config.xml` <a href="{{site.gdeurl}}mtf/mtf_quickstart/mtf_quickstart_config.html#mtf_quickstart_config_configxml_browser"> define the browser that the MTF will use for tests</a>.
3636

3737
Run the Selenium Server with an additional argument.
3838

3939
Example for Google Chrome:
4040

41+
4142
java -jar <path_to_selenium_directory>/selenium-server.jar -Dwebdriver.chrome.driver=<path_to_chrome_driver>/chromedriver.exe
4243

44+
4345
### Run generator {#mtf_quickstart_env_generator}
4446

45-
Generator generates fixtures, repositories and page objects. Once MTF is initialized, all classes will be pre-generated to facilitate creating and running the tests.
47+
Generator generates [fixtures][], [repositories][], and [page objects][]. Once the MTF is initialized, all classes must be pre-generated to facilitate creating and running the tests. Modules in the MTF are processed by generator in the same order that they are processed during Magento loading.
4648

4749
Enter in terminal:
4850

@@ -52,5 +54,17 @@ Enter in terminal:
5254
<h2 id="mtf_install_pre">Next Steps</h2>
5355
<a href="{{ site.gdeurl }}mtf/mtf_quickstart/mtf_quickstart_config.html">&lt;&lt; Adjust configuration </a> | <a href="{{ site.gdeurl }}mtf/mtf_quickstart/mtf_quickstart_runtest.html"> Test run &gt;&gt;</a>
5456

57+
<!-- LINK DEFINITIONS -->
58+
59+
<!-- Devdocs -->
60+
[fixtures]: {{site.gdeurl}}mtf/mtf_entities/mtf_fixture.html
61+
[repositories]: {{site.gdeurl}}mtf/mtf_entities/mtf_fixture-repo.html
62+
[page objects]: {{site.gdeurl}}mtf/mtf_entities/mtf_page.html
5563

64+
<!-- Internet -->
65+
[Selenium project website]: http://www.seleniumhq.org/download/
5666
[WebDriver]: http://docs.seleniumhq.org/about/platforms.jsp
67+
68+
69+
<!-- ABBREVIATIONS -->
70+
*[MTF]: Magento Testing Framework

0 commit comments

Comments
 (0)