Run Unit Test with DB / Composition

To run Unit Test with composition

  1. Check the “Run with composition” option and select the composition you wish to run your image in while running the Unit Tests.

Screen Shot 2016-11-10 at 10.16.52 AM.png

  1. 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

Screen Shot 2016-11-10 at 10.22.36 AM.png

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


version: '2'
    image: 'containers101/demochat:master'
      - 5000
      - mongo
    image: mongo
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.