With Codefresh, you can easily set your unit tests to run on every build.
You configure your unit test script inside the service's settings page or YML file.
- Click Pipelines (gear icon) on your service.
- Define your unit test script.
For example we input command(will print the date) - echo $(date)
Make sure your testing frameworks are installed in your service Docker image. For full documentation on Dockerfile commands, visit the Docker documentation.
- Click Save and Build the project.
Expand the Running Unit Tests section to view the actions taken during the test.
For more information about the
codefresh.yml file, click here.
- Add a unit-test step to your
version'1.0' steps build-prj-name typebuild descriptioncodefresh example image-namecodefreshexamples/expressangular dockerfileDockerfile taglatest unit-tests imagenode latest # image that contains installed tools for performing test commands commands echo $(date)
- In your pipeline switch to the Use YML build
- Click Save and Build
A Composition is a number of containers that define a micro-services based application. For example, it can include all services, or a sub-subset of services.
- Select the 'Run tests with composition' check box.
- Select a composition.
- Choose a 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.