Test frameworkEdit on GitHub
To easily test every aspect of Spryker and the code you write, Spryker uses the Codeception testing framework and PHPUnit.
We strongly recommend reading the documentation of both frameworks to get the best out of your tests.
Codeception offers many handy things to write better and cleaner tests. Many solutions this framework has are built on top of PHPUnit. In the next articles, we will only reference Codeception even if these features are available in PHPUnit as well.
On top of Codeception, we have built the Testify module, which provides many handy helpers. See Testify Helpers for details on the existing helpers.
codeception.yml in the root of your project is the main entry point for your tests. In this file, the basic configuration for your test suite is defined.
From this file, you can include other
codeception.yml for a better organization of your tests.
namespace: PyzTest actor: Tester include: - tests/PyzTest/*/* ...
See codeception.yml in Spryker Master Suite for example.
For more information, see Codeception configuration documentation.
There are many console commands provided from Codeception, but the most used ones are:
vendor/bin/codecept build- generates classes
vendor/bin/codecept run- executes all your tests
For information on other Codeception console commands, run
See Executing Tests for details on some commands.
Testing with Spryker
On top of Codeception, we have added a basic infrastructure for tests. We have divided our tests by the applications, and for the layer we test. Thus, the organization of tests in most cases looks like this:
tests/OrganizationTest/Application/Module/Communication- for example, controller or plugin tests.
tests/OrganizationTest/Application/Module/Business- for example, testing facades or models.
The Business suite can contain unit and functional tests. The facade test is one kind of an API test approach. For more information, see Test API.
All test classes follow the exact same path as the class under test, except that tests live in the
tests directory, and the organization part of the namespace is suffixed with
Test. For example,
tests/PyzTest/*. For details on the
tests directory structure, see Directory Structure.
Each test suite contains a
codeception.ymlconfiguration file. This file includes, for example, helpers that are enabled for the current suite.
For example, check the organization in the Application module of Spryker Master Suite.
- Set up an organization of your tests.
- Learn about the available test helpers.
- Create or enable a test helper.
- Learn about the console commands you can use to execute your tests.
- Configure data builders to create transfers your tests.
- Generate code coverage report for your tests.
- Learn about the testing best practices.
For submitting the form