CodePark/ questions / Strategy & the test pyramid
START PRACTICINGPRACTICE
Backend question · Backend testing › Strategy & the test pyramid

Which of these is an integration test rather than a unit test?

Running UsersRepository.findByEmail() against a real Postgres started by Testcontainers

"Running UsersRepository.findByEmail() against a real Postgres started by Testcontainers" is the integration test. It runs your code together with a real external dependency, and that is what makes a test an integration test.

"Checking that
OrderService.place() calls a mocked PaymentGateway.charge() once" feels bigger, because it checks how two parts interact. But every collaborator in it is a test double (a fake), so it is still a unit test.