Conclusion With the emphasis firmly on the importance of testing in XP, this chapter has provided you with tools you need to tests user interfaces and other people's code. The lesson I hope you take away from this chapter is that you can write tests to cover most eventualities, and you should always start the process of development by writing the tests first. The tests validate the quality of your code and document your assumptions as to how the code will be used. They provide the communication and the feedback while driving you toward simpler solutions. The tests embody these three values that XP holds in high regard.This chapter explored two techniques you can use to write more testable user interfaces. First, you learned how by encapsulating more functionality in classes away from the user interface, you can develop tests first and build code that is user-interface agnostic. Then this chapter examined how you can use reflection to call methods that are attached to the user interface.Then this chapter covered how to deal with using third-party libraries and validate that they are performing how we expect and provide the functionality we require. Finally, we walked through some exercises in fixing existing code that contains bugs.All that's left to do now is put all these practices together. In the next chapter, we do exactly that; we will work on a project using all the practices covered in this book. I have more than once made a recommendation to ditch some code that attempted to do far more than was required of it and was not working correctly. Gold plating is one of the evils of software development that eXtreme Programming attempts to remove from the equation. |