DEV Community

Cover image for Integration Testing : Concept
Jayant
Jayant

Posted on

2

Integration Testing : Concept

Integration Testing

What

In Integration Testing we test how all the components work together, means unlike unit tests we don't have to mock out the services. We actually start all the services in the integration test and see how they work together.

Downside to this is that it is slower, as we have to start all the auxiliary services.

Here is a gist of what we have to do in the Integration Testing

Testing

How

To do the integration test we will use scripts and docker compose file.

  • docker-compose.yml file - It will start all the services
  • script file - It will run docker compose file, wait for our DB , migrate the DB , Do the Intial Seeding and run all the tests.

run-integration.sh

docker-compose up -d
echo '🟡 - Waiting for database to be ready...'
# The below command will wait for the DB after that all the command run.
./wait-for-it.sh "postgresql://postgres:mysecretpassword@localhost:5432/postgres" -- echo '🟢 - Database is ready!'
npx prisma migrate dev --name init
npm run test
docker-compose down

# To run this file simply do `run-integration.sh` + you need to install wait-for-it.sh from github.
# curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -o scripts/wait-for-it.sh
Enter fullscreen mode Exit fullscreen mode

For All the Steps Visit - 100xdevs Integration Testing

Thanks

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay