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:
Create Sub-folders: Inside the
testsdirectory, create the desired sub-folders for your test suites. For example, you can create
unitfolders to categorize your test types.
tests ├── acceptance ├── functional ├── unit ├── _bootstrap.php └── ...
Configure Suite Paths: In your Codeception configuration file (
codeception.dist.yml), specify the paths to the test suites in the
suitessection. Make sure to include the sub-folders in the paths.yaml
# 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
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:arduino
vendor/bin/codecept run acceptance
To run functional tests:arduino
vendor/bin/codecept run functional
And for unit tests:arduino
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.