Run Unit Test with DB / Composition
To run Unit Test with composition
- Check the “Run with composition” option and select the composition you wish to run your image in while running the Unit Tests.
- Now select the candidate service from your composition which Codefresh will use to run your unit tests on. Notice that the image of that candidate will be replaced with the built image from the previous step
Composition are set in the Composition module.
Dependencies and execution order
Please note, you can use the “depends_on” option in the compose file to force starting the db container before the test container such as the example below
depends_on doesn’t guarantee that db is “ready”
depends_on will not wait for db to be “ready” before starting the test service - only until they have been started. If you need to wait for a db to be ready, see Controlling startup order for more on this problem and strategies for solving in docker compose.