Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 3.83 KB

new_test.md

File metadata and controls

80 lines (55 loc) · 3.83 KB
layout group subgroup title menu_title menu_order version github_link
default
mtf-guide
40_Approach
Create a test in the Functional Testing Framework
New functional test. Theory
2
2.0
mtf/create_test/new_test.md

The FTF helps to create a new test, you can extend an out-of-the-box test, or create a completely new test.

Extend an out-of-the-box test {#extending-oob-test}

You can extend a test by adding or replacing a test entity. Test entities for the module are stored in the <magento2_root_dir>/dev/tests/functional/tests/app/Magento/<testing_module> directory.

Usage {#ext-usage}

This approach is useful when the Magento functionality was extended. For example, the minor changes were made in the existing functionality of a {% glossarytooltip c1e4242b-1f1a-44c3-9d72-1d5b1435e142 %}module{% endglossarytooltip %}. Also you can extend an out-of-the-box test to extend the current test coverage if the target functionality is not completely covered by the out-of-the-box test.

Example use cases:

Create a functional test {#create-test}

If new modules are added to Magento you would need to create a new test to check the functionality.

New test must be stored in the corresponding module <magento2_root_dir>/dev/tests/functional/tests/app/Magento/<testing_module>.

Each test consists of four main components: a test object, test data, a test flow, a test assertion.

Test object {#test-object}

A test object is an object that you are going to test. Most of the test actions are performed under this object. The test object is represented by a fixture. The fixture defines properties of an object.

Test data {#test-data}

There are two types of test data:

  • Data for the test, stored in a data set.
  • Preconditions:
    • Sample data that is stored in a fixture repository. In a data set, it is stored as a name of the fixture repository.
    • A sample test entity that can be created by a handler.

Test flow {#test-flow}

A test flow is a set of test steps that you want to perform under the test object to check required functionality. Test steps are defined in a test case. Usually, a test step contains a set of actions. Each action is managed by a method defined in a block. A page is a container for blocks. It stores selectors to identify blocks on an {% glossarytooltip a2aff425-07dd-4bd6-9671-29b7edefa871 %}HTML{% endglossarytooltip %} page.

Test assertions {#test-assertions}

A test assertion compares the test flow results with the expected ones. Test assertions are represented by constraints.

Learn more in the "Create a new test" topic.