UnitGPT is a small extension that will help with creating code and unit tests with the power of openAI.
To create a code suggestion simply write: // ### instructions here ### any where in the active document and press Alt+C or the menu option available under Edit.
The generated code will be inserted under the instructions:
Make sure the test project is referenced under the setting for the extension and that the correct framework for the testproject is selected
Highlight the code you want to create unit test for and press Alt+U or the menu option available under /Edit and a new test file will be created in the selected xUnit project.
The extension has three option.
- The key that is required to make the openAi api calls. You will need to register on https://platform.openai.com/account/api-keys and create your own key.
- The test project where you want to place you're generated unit tests.
- The type of the test generated.
Project specific settings
As another option you can create a file named unitgpt.json in the root of the project and that way have project specific settings. The file will take precedence over the options set in the gui.
Troubleshooting Guide for UnitGPT
Problem: Code suggestion is not generated.
- Check that the UnitGPT extension is installed and enabled in your Visual Studio.
- Ensure that you have included the following comment anywhere in the active document:
// ### instructions here ###.
- Make sure you are pressing Alt+C or using the correct menu option under Edit to trigger the code generation.
- Verify that you have a stable internet connection to access the OpenAI API.
- If the issue persists, try restarting Visual Studio and attempting the code generation again.
Problem: Generated code is not inserted as expected.
- Ensure that the
// ### instructions here ### comment is correctly placed in the active document.
- Verify that you are pressing Alt+C or using the menu option under Edit after adding the comment.
- Check if there are any syntax errors or conflicts in the code that prevent the generated code from being inserted.
- If the issue persists, try closing and reopening the document or restarting Visual Studio.
Problem: Unable to create unit tests.
- Confirm that the test project is referenced correctly in the settings of the UnitGPT extension.
- Check that the appropriate framework for the test project is selected. Ensure compatibility between the framework and the test project.
- Highlight the specific code for which you want to create a unit test.
- Press Alt+U or use the menu option under Edit to initiate the unit test generation.
- Make sure you have the necessary permissions to create files in the selected xUnit project.
- If the test file is not created, check for any error messages or notifications that may provide additional information.
Problem: API Key is not working.
- Ensure that you have registered on https://platform.openai.com/account/api-keys and obtained your own API Key.
- Double-check that the API Key is correctly entered in the UnitGPT extension settings.
- Confirm that the API Key has not expired or been revoked by OpenAI.
- Verify that your internet connection is stable and allows communication with the OpenAI API.
- If the problem persists, try generating a new API Key and updating it in the extension settings.
Problem: Unable to specify the test project or type of test generated.
- Check the extension's settings to ensure that the test project option is available and properly configured.
- Verify that you have the necessary permissions to modify the test project and create unit tests.
- If the test project is not selectable or editable, confirm that it meets the requirements of the UnitGPT extension.
- Ensure that the test type option is accessible and choose the desired type for the generated tests.
If you encounter any persistent issues or errors that cannot be resolved using this troubleshooting guide, consider reaching out to the UnitGPT extension support team for further assistance.