Extended Role of QA in Test-Driven Development (TDD)
Test-driven development, most commonly known as TDD, is an agile development technique across software engineering. In TDD, the software engineering teams write test cases before writing the corresponding code for the user story assigned to them. The moment code passes Acceptance test, it gets refactored for production.
TDD focuses on creating the necessary code to pass the test, and thus makes the process simple and intelligible.
What is the Primary Goal of Test-Driven Development (TDD)?
In a software engineering team, the primary goal of Test-Driven Development is to enable developers to think through the crucial requirements. These include synonymous like a Quality Assurance engineer does before writing functional code and creating Unit test cases to be executed in the development environment.
Test-Driven Development: A Different Approach
In the normal development phase, software engineering teams including developers write code. This is followed by unit testing. In case of any errors, the developer fixes them. This is a continuous cycle until the code gets released to quality assurance teams.
On the contrary, in Test-Driven Development, software engineering teams write test cases first rather than the code. The test is then run, irrespective of the code, to fail intentionally. Subsequently, the developer starts creating classes and adds functionalities to ensure the test passes this time. This cycle gets repeated to add newer functionalities.
The 6-Step Cycle of Test-Driven Development
Test-Driven Development is a process followed by software engineering teams. The core areas of the 6-step TDD cycle include the following:
1. Add New Test
The first step includes adding a test case without implementing the code. This helps the engineering team, especially developers to get a clear understanding of the requirement before writing the actual program code.
2. Execute Tests to Ensure Code Failure
If the new test case fails as it should (because the test case was executed without any code), then both the test environment and test case are working fine.
3. Write Code
The third step of the test-driven development process include writing the code. This time the developer must ensure that the code passes the test this time successfully. After successful testing, the new code must be updated, as per the requirements of the test case.
4. Run Automated Tests
After successful testing and writing code, the next step is to run automated tests. For every automated test, if the result of every test case is success, it directly implies that the code meets all required specifications by the client.
5. Refactor Code
Once the code meets the standards and requirements, refactoring is the next important process of the test-driven development. Refactoring helps in removing duplication between production and test codes without doing any damage to existing functionality.
Post refactoring, the complete cycle gets repeated in the Test-Driven Development as per the above steps with a new test.
Challenges and Limitations of Test-Driven Development (TDD)
Though the test-driven development has a different approach with a 6-step cycle, it is bound by certain challenges and limitations. Some of which are mentioned below:
- The initial learning curve of the Test-Driven Development for software engineering teams is steep.
- The time invested in Test-Driven Development (TDD) is long for minor bug fixes.
- The TDD approach is cumbersome when applied to maintenance projects where the focus is on fixing micro bugs and carrying out minor enhancements.
- TDD implementation is complex in projects where the requirements are not explicit initially but get cleared up down the line. In such instances, it becomes increasingly difficult for engineering teams ‚Äď software developers & QA to derive test cases with correct expected results.
What is the Role of QA - in a Test-Driven Development Environment?
Across engineering teams, both development and quality assurance engineers use test cases to develop code & execute them. So, the success of TDD is dependent on well-written test cases covering all the requirements.
It is essential to involve the QA team in every phase of TDD. They test the system end-to-end and so have better knowledge of the overall systems. The QA team should work together with the developer to build unit testing into the application core.
Acceptance Test-Driven Development (ATDD)
In the planning phase, the QA elicits requirements from customers and collaborate with developers to create test cases. This collaboration ensures better test coverage. However, QA can also set up the acceptance tests upfront, which achieves Acceptance Test-Driven Development (ATDD).
Software engineering teams have different approaches to acceptance test-driven development. While developers are concerned with the functional implementation for individual units, the QA is concerned about how the individual units integrate to form the complete system.
Advantages and Benefits of Test-Driven Development for Engineering Teams
Test-driven development approach enables engineering teams with the following benefits:
- Developers gain better insights into project requirements leading to the creation of a good, relatively bug-free product.
- Quality Assurance engineers can identify bugs early in the testing phase.
- It is easy to assess whether existing functionalities get affected when new ones are added.
- With the testing phase likely to see fewer unit/regression bugs, there is better bandwidth to address real-time issues.
The Extended Role of QA in Agile
Firstly, one needs to understand that Test-Driven-Development (TDD) is not a QA method, it is a development approach.
- Test-Driven-Development is moreover meant to restrict itself to unit testing only
- Having a separate engineering team of developers and testers has benefits of increased specialization, when any product is needed to be tested on multiple hardware/software platforms independently
- QA is involved in Agile all the way through and it is an integral part of any team designing the test cases when the requirements are still evolving
- An independent testing team serves as an objective third-party and they are able to see "the AUT in complete end-to-end sense". The testing team helps in validating the functionality while also keeping in terms the quality of the product. While the tendency of a developer is to prove that the AUT functions as required, a good test engineer will always ask "what happens if...?"
Looking to understand how Digital Quality Assurance and Specialized Quality Engineering can enable your engineering teams?