Cest structure in the Magento Functional Testing Framework
This topic was updated due to the 1.0.0 MFTF release.
Overview
Test cases in the MFTF are defined in XML as cests. A Cest is Codeception test container that contains multiple individual tests with cest-level metadata and before/after actions with dependency management. Tests in the MFTF are considered as a sequence of actions with associated parameters. Any failed assertion within a test fails that test and the MFTF reports it using Allure.
The following diagram demonstrates XML structure of a Cest in the MFTF:
Format
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-acceptance-test-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
<cest name="">
<annotations>
<features value=""/>
<stories value=""/>
<group value=""/>
<env value=""/>
</annotations>
<before>
<!-- LIST OF ACTIONS -->
<click selector="" stepKey=""/>
<!-- ACTION GROUPS -->
<actionGroup ref="" stepKey="">
<argument name="" value=""/>
</actionGroup>
</before>
<after>
<!-- LIST OF ACTIONS -->
<click selector="" stepKey=""/>
<!-- ACTION GROUPS -->
<actionGroup ref="" stepKey="">
<argument name="" value=""/>
</actionGroup>
</after>
<test name="">
<annotations>
<title value=""/>
<description value=""/>
<severity value=""/>
<testCaseId value=""/>
</annotations>
<!-- LIST OF ACTIONS -->
<click selector="" stepKey=""/>
<!-- ACTION GROUPS -->
<actionGroup ref="" stepKey="">
<argument name="" value=""/>
</actionGroup>
</test>
</cest>
</config>
Principles
- One
*.xml
, one<cest>
- File name and
<cest>
name are equal - All names within the framework are in the CamelCase format
- A test may have any number of assertions, at any point within the
<test>
Reference
The following list is reference documentation of elements that may be used in Cests.
cest
A cest is a Codeception container for multiple tests. Logically, it is a group of tests that define test flows within a test case.
Attribute | Type | Use |
---|---|---|
name | string | required |
It MUST contain at least one <test>
.
It MAY contain <annotations>
, <before>
, <after>
.
annotations
Annotations are supported by both Codeception and Allure. Codeception annotations typically provide metadata and, also, they are able to influence test selection. Allure annotations provide metadata for reporting.
Read about annotations in a separate topic Annotations.
before
Specifies actions to perform before all tests in a cest.
Attribute | Type | Use | Description |
---|---|---|---|
name | string | optional | |
remove | boolean | optional |
It MAY contain the following child elements:
- any action
<actionGroup>
after
Specifies actions to perform after all tests in a cest.
Attribute | Type | Use | Description |
---|---|---|---|
name | string | optional | |
remove | boolean | optional |
It MAY contain:
- any action
<actionGroup>
test
A set of actions with an assertion.
Attribute | Type | Use | Description |
---|---|---|---|
name | string | optional | |
remove | boolean | optional |
It MAY contain:
actionGroup
Calls a corresponding action group.
Attribute | Type | Use | Description |
---|---|---|---|
ref | string | required | Reference to the required action group by its name . |
stepKey | string | required | Identifier of the element within <test> . |
before | string | optional | <stepKey> of an action or action group that must be executed next while merging. |
after | string | optional | <stepKey> of an action or action group that must be executed one step before the current one while merging. |
It MAY contain <argument>
argument
Sets an argument that is used in parent action group tag.
Attribute | Type | Use |
---|---|---|
name | string | optional |
value | string | optional |