In Test Driven Development model the testcases drive the design One should write a testcase and then develop a code for the test case to pass. But the developers first develop the code and then write test cases for it. This is a wrong pattern that everyone follows. The reason is first we have to identify the problem, develop testcases for the problem and then develop a solution for it. The reason for writing the testcases is it keeps you focused on the purpose of the code.
The reason for developers not testing the code are
- They think that their code already works
- They think that they don't write the broken code
- They have no time to test the code
The Basic TDD workflow is
- Write a testcase that fails
- Write a code to make the testcase pass
- Improve the quality of code by optimising the code
- Repeat the steps 1 to 3 during the process.
Why is TDD important for DevOps
- It saves time when developing the applications.
- You can't code faster and with more confidence.
- It ensures the code is working as expected.
- It ensures that future changes don't break your code.
- In order to create a DevOps CI/CD pipelines, all testing must be automated.