Back to the basics: Tests, part 1
In the software world, exits a lot of types of tests, but for a developer in your normal workday, three of them are important, unit tests, integration tests, and end-to-end tests.
These types represent the famous pyramid of tests, where the base represents the number of tests and effort we must spend, and the high is how expensive is it.
So analyzing this, we can see that we must spend our effort on unit tests, after integration tests, and end-to-end minimal.
But what are these tests types? What are their proposals?
- Unit tests: As the name suggests, this is a type of test that only will test a single unit in a single scenario. For example, if we have a function sum that receives two parameters "a" and "b", we easily can stress out this function by writing a lot of test cases by testing if is correct, if breaks, if it has good defensive programming, and so on.
- Integration tests: Applications are more complicated than a simple function that sum up two numbers, probably we will have a lot more functions that will become bigger, and other integrations like databases and other systems. As we already guarantee the good functionalities of our little functions with unit tests, in integrations tests we will focus on testing the integration between the units and check if everything is good inside our system, without worrying about the third parties yet.
- End-to-end tests: As the name already said, let's test everything together! This is where we will spend a lot of time because we already guarantee a lot of things, and when we will test something out of our system we do not have any control, making this type of test fragile.
Remember the pyramid, Unit tests are the base, where we really will dedicate of effort to stress the functionalities individually to guarantee that each piece works properly, but Unit tests by itself it is not sufficient, and we go up to our pyramid to integration tests, where we will look how each individual part works together, as complexly the cost to maintain and stress out is higher, so we will focus on the most important scenarios.
After the end-to-end is really to see everything and the cost to maintain is really high because of all the components, so we need to dedicate the critical paths into it.
This concludes the first article in the series, after which we will see how to write these. Bye!
Previous part
Previous part