Guerrilla
Guerrilla

Reputation: 14886

Running tests with Visual Studio Docker compose support

I have added docker compose to my project. When I debug the project it loads the docker compose file. In the override yml I have specified a postgresql image and volume so it automatically brings up the development database. This is great because you can clone repo and not have to install any local software apart from docker.

The only thing that is not good is running tests. When I run tests it doesn't bring up the database container, it just executes the code inside the test project. So tester has to manually start the database image.

I feel like I am probably doing something wrong. Is there a better way to make the tests work with the visual studio docker compose support so it brings up the database automatically?

I thought about running the tests inside the docker file but I think that might get in the way of development. What is a good approach here?

Upvotes: 3

Views: 727

Answers (1)

grizzthedj
grizzthedj

Reputation: 7505

I would not recommend running tests inside your Dockerfile. This will complicate your development process as you have said.

In terms of the database, you can just run it outside of docker-compose so that it is always running in the background. Just remove the postgres config from your docker-compose.yml and run postgres with docker run ... instead. This way it will always be running until you stop it with docker stop ...

docker run -v /tmp/pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=<PASSWORD> -d postgres

Upvotes: 1

Related Questions