-
Book Overview & Buying
-
Table Of Contents
Supercharged Coding with GenAI
By :
In this chapter, we explored various aspects of testing using GenAI. Although there are many types of tests and they are the topic of many books, the most common tests are unit tests. In unit testing, each test should test a single point of functionality and should be independent of other tests. Together, a complete set of unit tests proves that the code implementation functions as expected. If the code is refactored, augmented, or integrated in the future, the same unit tests assert the correctness of the functionality.
The chapter described a few approaches to creating tests from the implementation. GitHub Copilot and ChatGPT can both be used to easily write unit tests for a single method or an entire Python file. Both techniques have some variability in terms of the types of tests and coverage that they provide in a first pass. In some cases, the tests may not be correct and may need additional prompting or manual correction. In other scenarios, prompting may be useful...