mardi 18 septembre 2018

Unit test definition - Scope and Mocking external dependencies

I have a confusion regrading the definition of unit test.
I think unit tests is about mocking external dependencies, the scope can be large like IT test (more than one class). In this way of thinking, I can test in my UT complete flow and that can help me catch bugs fast, (I'm not using Spring, I'm not using external dependencies), I want to catch bug fast because if I'm doing refactoring, I want to run my tests every few minutes to see if something's broken so I need my tests to run fast. (That's why I only want to run UT and not IT tests).

It seems that in the industry, when talking about UT, UT should be small (scope), and also mock external dependencies. I don't think this is a good way of thinking, because that means that my UT can miss bugs that IT catches, which means that running only UT every few minutes is not good enough and I should run IT tests which is much slower which is not good for me because the refactoring process will take me much longer.

So what Am I missing something? Why not to write UT that tests complete flows just like IT but with mocking of external dependencies? Thanks

Aucun commentaire:

Enregistrer un commentaire