How to: Run tests with Docker#
If you want to skip the installation of AltWalker you could use one of our docker images.
Create a Dockerfile
for your project#
To use altwalker with docker add the following Dockerfile
in the root
of your project.
FROM altwalker/altwalker:latest
COPY . /test-project
WORKDIR /test-project
RUN touch requirements.txt
RUN python3 -m pip install -r requirements.txt
# If you have other dependencies you can install them here.
FROM altwalker/altwalker:latest-dotnet-2.1
COPY . /my-tests
WORKDIR /my-tests
# If you have other dependencies you can install them here.
RUN dotnet build tests
You can then build and run the Docker image:
docker build -t my-tests .
docker run -it my-tests altwalker online [...]
Example:
docker build -t my-tests .
docker run -it my-tests altwalker \
online tests -m models/default.json "random(vertex_coverage(100))"
Run your tests as a script#
For many projects you may find it inconvenient to write a complete
Dockerfile
. In such cases, you can run you tests as a script by
using the AltWalker Docker image directly:
docker run -it -v "$(pwd):/test-project" -w "/test-project" altwalker/altwalker:latest \
/bin/bash -c 'python3 -m pip install -r requirements.txt && altwalker online [...]'
If you don’t have any python dependencies you can remove the python3 -m pip install -r requirements.txt
.
docker run -it -v "$(pwd):/test-project" -w "/test-project" altwalker/altwalker:latest \
altwalker online [...]
docker run -it -v "$(pwd):/test-project" -w "/test-project" altwalker/altwalker:latest-dotnet-2.1 \
altwalker online [...]
Example:
docker run -it -v "$(pwd):/test-project" -w "/test-project" altwalker/altwalker:latest \
/bin/bash -c 'python3 -m pip install -r requirements.txt && altwalker online tests -m models/default.json "random(vertex_coverage(100))"'
docker run -it -v "$(pwd):/test-project" -w "/test-project" altwalker/altwalker:latest-dotnet-2.1 \
altwalker online tests -m models/default.json "random(vertex_coverage(100))"