This extension utilizes a RAG Based approach to refactoring and generating new unit tests
Features
Simply open up the copilot chat button and use @unit-test-generator /gen to get started
Setup
Ensure that you have the Github Copilot Chat VSCode extension installed
Please acquire the Cognitive Services OpenAI User and Cognitive Services User role assignments for the servicehubtest deployment resource to get started
Run az login in Windows/Ubuntu depending on where the VS Code extension is running
Set your az account subscription to "AKS Long Running Things"
az account set --subscription 359833f5-8592-40b6-8175-edc664e2196a
Usage
Use Cases
Test Refactoring
Generating additional tests based on existing ones
Generating brand new unit tests from scratch
For test refactoring and generating additional tests, please ensure that you have your <filename>.go and <filename>_test.go files created with a couple of sample tests to provide a good seed.
Otherwise, for generating brand new unit tests, only the <filename>.go is necessary.
Workflow
Open the copilot chat extension and tag the unit test generator chat participant along with the gen command to get started
@unit-test-generator /gen <prompt>
Before hitting enter, please click on the <filename>.go file and open it in your vs code window so we can include that as part of the context for the LLM.
Attach any existing test files and/or test files that need to be refactored using the #file reference within the prompt
After that, you just need to wait for the extension to complete the task and you will find the generated unit tests in “generated_unit_tests” file
You will also find that a few other files have been created such as debug_log.txt, etc. This is to assist in debugging in case the output of the LLM was not as expected.