Reputation: 25
How can i perform unit test inside a module. here's my project structure
Upvotes: 0
Views: 427
Reputation: 14102
yii2-app-advanced is a good example of solution.
Add include
section to project level codeception.yml file:
include:
- modules/api
- modules/dtr
Include
setting is documented at https://codeception.com/docs/08-Customization#One-Runner-for-Multiple-Applications
You need codeception.yml file in modules/dtr directory, it lools like normal standalone codeception.yaml file.
codecept run
command would run project level tests and tests of included modules.codecept run modules/dtr/tests/unit/
executes all unit tests of that module.codecept run modules/dtr/tests/unit/models/FirstTest.php
executes specific testIf you don't want to have a top level codeception.yml file, you can specify path to module directory (you need codeception.yml file there anyway).
codecept run -c modules/dtr
executes all testscodecept run -c modules/dtr tests/unit/models/FirstTest.php
executes specific testcodecept run -c modules/dtr :FirstTest
-c
parameter is documented at https://codeception.com/docs/07-AdvancedUsage#Running-from-different-folders
Upvotes: 2