Skip to content

Small visual studio extension for creating code and unit tests with the power of openAI

Notifications You must be signed in to change notification settings

0handersson0/UnitGPT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

drawing

UnitGPT

Latest release | Visual studio marketplace

UnitGPT is a small extension that will help with creating code and unit tests with the power of openAI.

CreateCodeDemo

Generate code

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.

image.png

image__1.png

The generated code will be inserted under the instructions:

image__2.png

Unit test

Make sure the test project is referenced under the setting for the extension and that the correct framework for the testproject is selected

image__4.png

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.

image__7.png

image__6.png

image__5.png

Options

The extension has three option.

  1. 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.
  2. The test project where you want to place you're generated unit tests.
  3. The type of the test generated.

image__4.png

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.

options

Troubleshooting Guide for UnitGPT

Problem: Code suggestion is not generated.

Solution:

  1. Check that the UnitGPT extension is installed and enabled in your Visual Studio.
  2. Ensure that you have included the following comment anywhere in the active document: // ### instructions here ###.
  3. Make sure you are pressing Alt+C or using the correct menu option under Edit to trigger the code generation.
  4. Verify that you have a stable internet connection to access the OpenAI API.
  5. If the issue persists, try restarting Visual Studio and attempting the code generation again.

Problem: Generated code is not inserted as expected.

Solution:

  1. Ensure that the // ### instructions here ### comment is correctly placed in the active document.
  2. Verify that you are pressing Alt+C or using the menu option under Edit after adding the comment.
  3. Check if there are any syntax errors or conflicts in the code that prevent the generated code from being inserted.
  4. If the issue persists, try closing and reopening the document or restarting Visual Studio.

Problem: Unable to create unit tests.

Solution:

  1. Confirm that the test project is referenced correctly in the settings of the UnitGPT extension.
  2. Check that the appropriate framework for the test project is selected. Ensure compatibility between the framework and the test project.
  3. Highlight the specific code for which you want to create a unit test.
  4. Press Alt+U or use the menu option under Edit to initiate the unit test generation.
  5. Make sure you have the necessary permissions to create files in the selected xUnit project.
  6. 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.

Solution:

  1. Ensure that you have registered on https://platform.openai.com/account/api-keys and obtained your own API Key.
  2. Double-check that the API Key is correctly entered in the UnitGPT extension settings.
  3. Confirm that the API Key has not expired or been revoked by OpenAI.
  4. Verify that your internet connection is stable and allows communication with the OpenAI API.
  5. 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.

Solution:

  1. Check the extension's settings to ensure that the test project option is available and properly configured.
  2. Verify that you have the necessary permissions to modify the test project and create unit tests.
  3. If the test project is not selectable or editable, confirm that it meets the requirements of the UnitGPT extension.
  4. 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.

About

Small visual studio extension for creating code and unit tests with the power of openAI

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages