6 Testing and prompt engineering
This chapter covers
- Understanding the importance of testing Copilot code
- Using closed-box versus open-box testing
- Addressing errors by Copilot by modifying prompts
- Working through examples of testing Copilot-generated code
In chapter 3, we first started to see the importance of testing the code produced by Copilot. Testing is an essential skill for anyone writing software because it gives you confidence that the code is functioning properly. In this chapter, we’ll learn how to test our code thoroughly and how to help Copilot fix code that doesn’t work by modifying our prompts.
Testing is an essential skill that you’ll need to learn how to do well on your own, so that you are able to check that the code works correctly. Copilot can generate tests, and has been improving in the quality of tests it produces, but we encourage you to hold off on using Copilot to generate tests just yet, because you need to learn to do this well enough on your own to be able to verify that the tests Copilot produces are reasonable. This will be true of the next few chapters as well – testing, problem decomposition, and debugging are all skills that are essential to learn how to do on our own, before asking for Copilot’s help, as we need to know how to do it on our own to know if Copilot is doing something reasonable.