This topic was updated due to the 2.2.0 MFTF release.
Test cases in the Magento Functional Testing Framework (MFTF) are defined in XML as
<tests> is a Codeception test container that contains multiple individual tests with test metadata and before and after actions.
<tests> is considered a sequence of actions with associated parameters.
Any failed assertion within a test constitutes a failed test.
<after> hooks are not global within
<tests> like in MFTF 1.0.
They only apply to the
<test> in which they are declared.
The steps in
<after> are run in both successful and failed test runs.
The following diagram shows the structure of an MFTF test case:
The format of
<?xml version="1.0" encoding="UTF-8"?> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> <test name=""> <annotations> <!-- TEST ANNOTATIONS --> </annotations> <before> <!-- ACTIONS AND ACTION GROUPS PERFORMED BEFORE THE TEST --> </before> <after> <!-- ACTIONS AND ACTION GROUPS PERFORMED AFTER THE TEST --> </after> <!-- TEST ACTIONS, ACTION GROUPS, AND ASSERTIONS--> </test> </tests> </config>
The following conventions apply to MFTF tests:
- All names within the framework are in the CamelCase format.
<test>name must be alphanumeric.
- Each action and action group has its own identifier
<stepKey>for reference purposes.
- A test may have any number of assertions, at any point within the
<test>is included in
<suite>, it cannot be generated in isolation to the rest of the contents of the suite (see suites for details).
There are several XML elements that are used in
<tests> in the MFTF.
<tests> is a container for multiple tests. It is a group of test methods that define test flows within a test case.
<tests> must contain at least one
||string||optional||A test identifier used while merging.|
Codeception annotations typically provide metadata and are able to influence test selection. Allure annotations provide metadata for reporting.
See more about Annotations.
<before> wraps the steps to perform before the
<before> may contain these child elements:
<after> wraps the steps to perform after the
The steps are run in both successful and failed test runs.
<after> may contain:
<actionGroup> calls a corresponding action group.
||string||required||References the required action group by its
||string||required||Identifies the element within
<actionGroup> may contain
<argument> sets an argument that is used in the parent
||string||optional||Name of the argument.|
||string||optional||Value of the argument.|
See more about Action groups.