CODEFRESH.IO DOCUMENTATION

Codefresh is a Docker-native CI/CD platform.

Instantly build , test and deploy Docker images.

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Run Unit Tests with DB

To run Unit Test with a DB or other services you shall create a composition and run your unit tests as part of it.

  1. Check the "Run with composition" option and select the composition you wish to run your image in while running the Unit Tests.
  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

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'
services:
  test:
    image: 'containers101/demochat:master'
    ports:
      - 5000
    depends_on:
      - mongo
  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.

Run Unit Tests with DB