The four developer practices of XP are:
- Adopt test-driven development
- Practice pair programming
- Adopt collective ownership
- Integrate continually
adopt test-driven development. :- The main reason for adopting test-driven development practice is to prove that the code developed works based on the requirement. XP emphasizes the need for testing every code as and when it is developed. You must test the code to check if the code actually does what it is intended to do and if anything can make the code to behave erratically. Usually traditional testing
is carried out by writing test cases to check the conditions under which the software fails. But XP also writes test cases to find out if the software passes the test. In XP, the development of a feature is said to be finished only when it passes the test. Therefore, test your code or feature whenever you get an opportunity to run a test. This gives the developer the confidence about the code. Also, you must run a test before and after refactoring your code. You must remember that finding a bug in few lines of code is easy, but finding the bug in a code with hundreds of lines is difficult.
Many automated testing tools or frameworks are available for testing. Using a good testing framework helps to save lot of time and resources. It also gives an accurate feedback about the status of the project any time. Manual testing may fail to identify or overlook certain bugs, but it does not happen in automated testing.
A good test must try to explore one issue at a time. When a code fails the test, you must have sufficient information to track the test to identify and debug the software. Therefore, you must use simple tests as they enable easy debugging when compared to complex tests. Usually tests are of two types:
- Unit test - This test is carried out to find out the behavior of the individual pieces or functions of the software.
- Acceptance test - This test is carried out to verify that the software features match the business requirements and expectations of the customer.
Every unique piece of code requires its own test case. The test case probes the limits of expected and unexpected use of the codes. It also serves as a guide for any future changes. Usually a well written unit test also tells you how to use the code.
The acceptance test case is written based on the customer’s requirements. You must work with the customer to write automated acceptance tests to prove to the customer that all the requirements are met successfully. Only when the software passes the acceptance test, the development is complete. Test-driven development supports refactoring to improve the software efficiency. It helps developers to ensure that the system is kept in good condition during every release. It also serves as a benchmark for future development. Any test-driven development method requires positive peer pressure to help developers to overcome the initial setbacks of test-driven development method and continue testing even if it seems difficult. At the same time, it is also essential to clearly communicate with the customer and obtain the test cases from the customer for acceptance tests.
- answered 3 years ago
- Sandy Hook