GopherCon Europe 2023: Elena Grahovac - Why Integration Tests Might be Better than Unit Tests

preview_player
Показать описание
About the talk: Go developers are widely encouraged to write unit tests to independently verify individual components within an application. This ensures that the application logic is correct and issues can be resolved early on.

However, in our case, we encountered a challenge where our unit tests were not reliable in detecting issues, leading to a false hope that the application was working correctly.

In this talk, we will share how we addressed this issue by shifting our focus towards integration tests. We will discuss the types of tests we chose to write and why.

#gopherconEU #golang
Рекомендации по теме
Комментарии
Автор

If I understand correctly, FerretDB is a re-implementation of MongoDB in Go. Since Mongo doesn't provide a spec, writing characterisation tests for FerretDB against MongoDB is a good approach. Good talk!

jubbs
Автор

I think the unit and integration tests are not comparable, it's like apple vs pear case. Each testing level has own advantages and disadvantages.

Unit test is good, when you write new unit or new code for a unit, and you need a quick feedback. This can work even if the feature is not implemented fully since it's about testing the unit. In addition, from security perspective unit tests can test the "impossible" paths within the code. And yes, the unit tests are relatively simple compared to the higher levels of testing.

Integration is good, when you want test the feature itself. So, units can work together to serve in a proper way. Testing deeply the feature most probably will require more complex code.

Both of them are important and they cannot replace each other.

I also think based on my experience in SW development that for a good product at least two different levels of testing are needed.

wazzzzzzzzzzeg