Member-only story

Integration testing like a boss with pytest-vcr

Anand Tripathi
Pythonistas
Published in
8 min readOct 11, 2023
Photo by Sigmund on Unsplash

Don’t forgot to subscribe the publication for more content like this 👇

The life of the programmer is never complete without a proper set of test cases. Whether it's a test case for an application or for some open source tool, testing of the code always requires a major chunk of time while writing code. It’s great until you are writing some unit test cases and functional test cases but when it comes to integration test cases. It is always a pain in the a***

Sometimes we just call the third-party APIs in the test cases and that leads to slow test cases and flaky test cases as it all depends on whether the third party if its available at that time or not. Or we ended up creating a lot of mock fixtures and mocking the actual API call with static response, thus creating a lot of maintenance overhead.

It's not required logically to call third-party API for every test run as we are not testing the third party instead we are testing the contract between the third party and our application. So wouldn't it be better to somehow call the third party only one…

--

--

No responses yet