Functional Testing Best Practices

Test Granularity

Since one class can have multiple tests (and a functional test which tests all the methods/buttons/links on a page can have an excessive number of tests) it's a good practise to break the files down as granularly as possible.

For example, a Codeception test will check the Events Admin page. This page has multiple tabs:

  • setup

  • content

  • history

  • attendance

  • statistics

Each tabbed display has multiple fields that need to be tested. To put all tests into one file would make it difficult to maintain the test file, and time consuming to test if the developer wanted to focus on a single tab. By breaking these down into multiple files, it makes development and amendments much more streamlined.


Codeception will recursively test all files in each directory.

In the event that a specific feature on a page requires extensive tests, it is recommended that it be put in a separate file for clearly readability.

File Naming Conventions

Codeception functional tests are to be named with 'Cest' at the end of the file name.


EventsSetupCest.php will be a Codeception test for the Setup tab on the Events page

CoursesCest.php will be a Codeception test for the Courses page

Last updated