Cest structure in the Magento Functional Testing Framework

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:

annotations actionTypeTags actionGroup 0..∞ before actionTypeTags actionGroup 0..∞ after actionTypeTags annotations actionGroup 0..∞ test 1..∞ 0..∞ cest 1..∞ config

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:



after

Specifies actions to perform after all tests in a cest.

Attribute Type Use Description
name string optional  
remove boolean optional  

It MAY contain:



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  
stepKey string required  
remove boolean optional  
before string optional  
after string optional  

It MAY contain <argument>



argument

Sets an argument that is used in parent action group.

Attribute Type Use
name string optional
value string optional