30
What’s the difference between unit test and integrated test, their benefits and examples to each other.
30
What’s the difference between unit test and integrated test, their benefits and examples to each other.
23
Unitary Test
Description: It’s a way to test individual units of source code. Drives can be methods, classes, features, modules, etc. It depends a lot on what the smallest part of your Software can be tested.
Goal: of the unit tests is to show that each unit correctly meets its specification.
Example: automatic tests designed to give inputs and check outputs to each method, allowing you to know that it is working as expected.
Benefits: find problems as soon as possible, facilitate unit change, simplify integration and improve documentation.
Integrated Test
Description: This is the way to test the combination of units together.
Goal: In this case, the idea is to find gaps in the junction of these units. It may be that the X class works well on its own, but when used by the Y class, it no longer works.
Example: Put all the software to run and start using various functionalities considered central in your program to confirm that it runs and the main functionalities do what is expected.
Benefits: In addition to testing functionally, it can ensure performance and reliability. They help ensure that one developer’s work is not affecting the work of another and in large teams this can make all the difference if they are performed frequently.
12
Complementing the rodrigo’s answer with examples:
Unitary Test (that purists like to call "unit test". Blorg! ): you have the following function in your system (super simplistic):
def soma(a, b):
return a + b
In your unit tests you will make "affirmations" (assertions) to make sure your function is working as it should. In Python:
assert soma(7, 1) == 8
assert soma(-1, -1) == -2
Integrated Test (or "integration test"): you have the following functions (again simplistic):
def soma(a, b):
return a + b
def multiplicacao(a, b):
return a * b
def minhaFuncaoNadaVer(a, b):
return soma(
multiplicacao(a, b),
multiplicacao(a + b, b)
)
After you have done Unit Tests for the functions soma
and multiplicacao
, now you will do a function Integration Test minhaFuncaoNadaVer
, after all it integrates two functions of your system (soma
and multiplicacao
). Python:
assert minhaFuncaoNadaVer(12, 6) == 180
assert minhaFuncaoNadaVer(1, 90) == 8280
Browser other questions tagged testing software-engineering tdd language-independent
You are not signed in. Login or sign up in order to post.
Code debugging can be considered a unit test ?
– Igor PTZ
Rogi93, although code debugging is a way to find a bug or problem that you know exists and fix the problem ends up not serving as unit test. The unit test should be something you will run repeatedly. If the test fails, then yes you will debug the code to find the problem and fix.
– Rodrigo Guiotti