One of many reasons for Test-driven development is the mere speed of testing: with automation I’ve managed to increase app testing speeds 5-fold.
More and more software development processes are run with lean methodologies. However, application testing is very often neglected in order to reduce initial costs and time. In this article I want to present the results of my experiment which is a proof that using Test-driven development doesn’t only pay off, but it also significantly enhances the quality of an app.
What is Test-driven development?
Before I describe the process of my experiment let’s highlight the most important steps of Test-driven development:
- Analyzing possible user actions and implemented data
- Writing up potential scenarios and test data
- Creating a software pieces and testing it
If the app we are making is complex, working with TDD may initially extend the time needed for a test. But what can we gain instead?
Test-driven development in Agile PLM
Combined with Agile methodology, TDD controls code quality and app security. Thanks to problem analysis and mocking up input data (correct and faulty examples as well) we can foresee a lot of potential scenarios. Then we can detect weaknesses and properly secure them at the very beginning. If you’d like to learn more about TDD , this Wikipedia article covers it very well.
In Agile lifecycle management, the team is working in a time-sensitive environment. And no matter how experienced developers are, they are prone to making mistakes when under pressure, especially faulty assumptions about data input or user behaviour.
Without automated tests, a developer must manually repeat the same steps over and over. He has to input the same data several times to check the correctness of a code action. It takes a lot of time, especially when the app is quite complex.
Test-driven development by example
For this article I’ve developed a mobile app which verifies a personal details form. To make the verification process more difficult, I’ve made a few extra conditions. For example, a surname must:
- Be single/one-word
- Consist of a-z characters
- Start with a capital letter
- Include at least 5 characters
Even though the number of conditions was so little, testing the correctness of the validator was difficult and it took about 20-30 minutes for the following: reinstall the app, input data and save the results. When it turned out that some conditions have to be changed, all the manual tests had to be retaken. As a result, the testing time of such a simple feature was extended to 2 hours.
I created the same app but this time in accordance with TDD guidelines. To make this experiment more credible, the time lag between these two attempts lasted about 2 weeks. I familiarized myself with all the requirements and started mocking up the test data (correct and incorrect examples). It took me about 15 minutes. In the beginning it was going smoothly, later I’ve turned to more fancy scenarios.
Having the data list at hand, I’ve created a project and wrote up unit tests. It took me around 15 minutes. Next, I started writing a code. Seeing the test data, I knew which cases I’d have to prepare my code for. Testing all data scenarios took less than a minute! If one of the tests failed, I implemented changes and with only one click restarted the whole process. Altogether, it took me about 10 minutes to test the code.
Summing up, app verification with Test-driven development lasted 5 time shorter than with manual test. I could now spend the saved time programming new features or fixing bugs. Most importantly, we created a working app which is less vulnerable to user errors.
If you work in web or mobile app development, and you practice Agile PLM, you should consider using Test-driven Development. You can save time to do tests or create features, and your dev team will gain a better understanding of the code. Change management will be less of a hassle, which will keep your costs low and reduce the number of unexpected situations.
Check out other agile methodology related articles on our blog.
Recently Kotlin programming is really endorsed by Google and most of the developers. We are not an exception. We moved to Kotlin for Android development and it was worth it. Here are 8 reasons why we did it.Read more
Do you want to develop your own mobile app, but not know how to estimate a mobile app development project? It all depends on the features, complexity and the selected platform. The price of a small application with basic functionality ranges from €8,931 to €44,653. Read on to find out more about estimating a mobile app.Read more