Ana Balica

Ana Balica

I am a software developer at Potato London. I've been using Django for the past 3-4 years and I think the framework has a good lifespan ahead of it due to a very active and empathetic community.

I am an introvert person who likes public speaking and programming for the sake of programming.

@anabalica

To mock, or not to mock, that is the question

Django is a multi-layered framework, where a ton of interactions occur. Testing such systems becomes more and more complicated. One way to separate some parts of some dependencies in tests is to use mocks. Mocking is a very powerful testing concept that has some dangerous pitfalls. There are obvious use cases where mocks are an absolute requirement to be able to test a part of any system (system calls, external services, API calls, IO operations). Nevertheless sometimes with mocks it becomes very easy to let various logic flaws creep in and ruin some test assertions.

It's bad to not have tests, but it's the worst to have misguiding tests. Quality of unit tests is as important as the presence of tests themselves.