Quidest?

Unit tests VS Integration tests

· Lorenzo Drumond

A unit test tests some unit of your code, such as a function, usually in isolation. Its job is to verify that the function’s logic is correct, so it tries to avoid using any external dependencies such as commands.

They need to be fast and lightweight, because we run them very often, and the only time they should fail is when something’s wrong with the code.

An integration test, on the other hand, has the job to test what happens when we do use those external dependencies. It validates our assumptions about how they work: for example, that we execute the right command in the right way.

Integration tests are not run as often as unit tests, because the only way they could break is if something external changed.

Unit tests check a program’s behavior given certain assumptions about external dependencies. Integration tests check those assumptions are still correct.

References

#integration #external #dependencies #unit #software #programming #safe #tests