GitHub Copilot is particularly skilled at generating unit tests based on existing code. As the developer writes test cases, they can ask the tool to examine the material and create appropriate unit test output. The developer can evaluate and accept the code, often reducing the amount of typing and time needed while creating efficiency around a tedious and simple but critical task.
Creating quality unit tests has long been a pain point – or simple annoyance – for developers. As a result, they often struggle to create quality unit tests. Common excuses for not writing test cases include:
a. I don’t have the time to do unit testing
b. I am paid to develop not write tests
c. I know how to break my own code
d. That is QA’s job
While excuses will always exist, Copilot can help eliminate some barriers that developers run into. The technology is skilled at generating many basic tests, freeing them up to instead focus on more complex tests.
But caution must be taken while using Copilot in this scenario. Copilot is good at generating simple tests based on the code it can examine, but it has no way of creating tests that are more custom or may be required to meet governing oversite. Developers still need to examine the output, write specific tests or write more complex tests that may require more oversight, interaction or coverage.
Also, Copilot is not a substitute for a good QA staff, robust CI/CD pipeline, proper stage gates or quality oversight. Relying on Copilot to replace QA can leave a company open to untested, non-performant and unsecure code being released into production.