Introduction
Unfortunately, it isn't common to see the test code in a mobile project. Because many people don't know the importance of testing, which is or how to do it.
According to the teacher of MIT Rob Miller [1], testing is a little part of a more general process called validation. Look the Figure 1 for understanding:
Why need to create tests?
10 reasons why the application needs tests:
1. Integration, you can integrate your tests code with a tool to validate the tests automatically by git flow for example.
2. Reduce bugs is a good practice to verify source code, but not necessarily a truth with a reduce bugs depends on the quality of tests.
3. Security using tests to check if your application is safety to attacks.
4. Assurance of the behavior of the application is in agreement with what the designer has created and the client need.
5. Refactor TDD or Test Driven Development has code refactoring in your step. Change the source code without a test is not a good practice.
6. Coverage is a number that represents to the developer how many your application covered with tests but not necessarily poses a quality of your code.
7. Documentation tests can be used as documentation of your application by the developer. The tests code shows how works the application code.
8. Clean Code it’s normal that many codes are created with unnecessary parts and refactor is a step of a developer to clear it.
9. Best Practices on a development flow, has as best practices a test step, an important step in software development, for example in Agile Processes [2] of Extreme Programming (XP), see Figure 2 [3]:
10. Show progress, we take a simple app for example with three layers: Presentation (UI, Controllers), Business (Service) and Data (Persistence). You can see clearly the progress with tests because you don’t need to wait for the Business layer to connect with Presentation, for example, you can use Mocks, Stubs or many others strategies for your tests.
Test in Project is very costly
Accord of Tom Fischer in your article [4] about myths of the test has two big myths:
First Myth, Tests saves money
If you think that your project will be less expensive that you do not use it, you are totally wrong. Fischer created a graph to shows a difference between a project with and without tests, see Figure 3 below:
When tests included in the project, initially is most expensive than another that not used it. But Fischer shows that across of the time the application costs more money because of increased support, bug fixes, deployment, lost customers, etc. You can get a point that he called the breakeven this point at which their unit testing pays off.
In the theory it’s perfect, but in the real world, we know that a project can be later and this graph will change, see Figure 4 below:
The difference after of breakeven point between the projects that are used and not used tests is different than previous graph (Figure 3) when people of team needs to extra hours, or the velocity decreases for any reasons.
Second Myth, Tests Reduce Bugs
Fischer defends that two services: X and Y have tests which individually pass, but when need to integrate between this services, may generate a different output that is not correct.
Figure 5 represents a simple communication between a mobile application and a server API. Each part has tests, but when integrated between them, the unit tests doesn’t insurance that will work correctly.
Agile programming has test action in your process
The Manifesto for Agile was created by seventeen people [5]. Kent Beck participated it. He’s created the Extreme Programming (XP) and introduced in Agile Programming the Test Driven Development or TDD, see the Figure 6:
Kent Beck defends that TDD is an important technique to development software with getting a high quality.
Continue... What is TDD?