Codeception allows you to organize your test suites and tests into sub-folders for better organization and manageability. By default, Codeception recognizes all test files under the tests directory. However, you can create sub-folders within the tests directory and organize your tests into those folders.

Here's how you can use sub-folders in Codeception:

  1. Create Sub-folders: Inside the tests directory, create the desired sub-folders for your test suites. For example, you can create acceptance, functional, and unit folders to categorize your test types.

    tests ├── acceptance ├── functional ├── unit ├── _bootstrap.php └── ...
  2. Configure Suite Paths: In your Codeception configuration file (codeception.yml or codeception.dist.yml), specify the paths to the test suites in the suites section. Make sure to include the sub-folders in the paths.

    # codeception.yml paths: tests: tests output: tests/_output data: tests/_data support: tests/_support envs: tests/_envs suites: acceptance: path: tests/acceptance actor: AcceptanceTester functional: path: tests/functional actor: FunctionalTester unit: path: tests/unit actor: UnitTester
  3. Run Tests: After organizing your tests into sub-folders and updating the configuration, you can run the tests using the specific suite names.

    For example, to run acceptance tests, use the following command:

    vendor/bin/codecept run acceptance

    To run functional tests:

    vendor/bin/codecept run functional

    And for unit tests:

    vendor/bin/codecept run unit

By using sub-folders in Codeception, you can keep your test suites organized and maintain a clear separation between different types of tests. This can help improve code readability and make it easier to manage and maintain your test suite as it grows.

Have questions or queries?
Get in Touch