A powerful Chrome extension that leverages AI to generate comprehensive unit tests for your Go/Golang code. Built with modern web technologies and integrated with multiple AI models for optimal test generation.
- AI-Powered Test Generation: Generate unit tests using advanced LLM models
- Multiple AI Models: Support for Mixtral, GPT, DeepSeek, and other models
- File Upload Support: Upload Go files directly for test generation
- Smart Code Detection: Automatically detects Go language and provides appropriate suggestions
- Real-time Validation: Ensures queries are related to testing and Go development
- Side Panel Integration: Seamless Chrome side panel experience
- Dark/Light Theme: Toggle between themes for comfortable usage
- Responsive Design: Works across different screen sizes
- Syntax Highlighting: Beautiful code display with Prism.js integration
- Chat History: Keep track of all your test generation sessions
- Model Benchmarking: Compare performance across different AI models
- Timer Integration: Built-in timer for productivity tracking
- File Generator: Export generated tests to files
- Quick Actions: Fast access to common testing tasks
-
Download the Extension
-
Open Chrome Extensions Page
- Navigate to `chrome://extensions/`
- Enable "Developer mode" (toggle in top right)
-
Load the Extension
- Click "Load unpacked"
- Select the extension folder
- The extension should now appear in your extensions list
-
Pin the Extension
- Click the puzzle piece icon in Chrome toolbar
- Find "Golang Unit Test Generator" and pin it
The extension will be available on the Chrome Web Store for easy installation.
The extension uses Groq API by default. To use your own API key:
- Open the extension options page
- Navigate to Settings
- Enter your API key for the desired service
- Save the configuration
- Groq (Default): Fast inference with Mixtral models
- OpenAI: GPT-3.5 and GPT-4 models
- DeepSeek: Advanced reasoning capabilities
- Custom APIs: Configure your own endpoints
-
Open the Extension
- Click the extension icon or use the side panel
- The interface will open with a welcome message
-
Enter Your Query
- Type your testing-related question
- Upload a Go file if needed
- Select your preferred AI model
-
Generate Tests
- Click Send or press Enter
- Wait for the AI to generate comprehensive tests
- Copy the generated code to your project
``` Generate unit tests for a Go function that calculates fibonacci numbers
Create table-driven tests for my HTTP handler function
Write benchmark tests for my sorting algorithm
Generate mocks for my database interface ```
- Click the file upload button (π)
- Select your Go source file
- The file content will be loaded into the input
- Ask for specific test generation based on the code
``` golang0-unit-test/ βββ assets/ # Icons and images βββ options/ # Extension options pages β βββ index.html # Main settings page β βββ chatHistory.html # Chat history viewer β βββ modelBenchmark.html # Model comparison β βββ ... βββ manifest.json # Extension manifest βββ popup.html # Main extension popup βββ popup.js # Main extension logic βββ background.js # Service worker βββ style.css # Main styles βββ README.md # This file ```
- `manifest.json`: Extension configuration and permissions
- `popup.js`: Main application logic and AI integration
- `fileHandler.js`: File upload and language detection
- `background.js`: Service worker for extension lifecycle
- `options/`: Settings and configuration pages
- Frontend: HTML5, CSS3, Vanilla JavaScript
- AI Integration: Groq API, OpenAI API
- Code Highlighting: Prism.js
- Storage: Chrome Storage API
- UI Framework: Custom CSS with modern design patterns
-
Clone the Repository git clone https://github.com/Rizald95/golang0-unit-test
-
Install Dependencies No build process required - pure vanilla JavaScript
-
Load in Chrome
- Follow the installation instructions above
- Make changes to the code
- Reload the extension in `chrome://extensions/`
-
Testing
- Test with various Go code samples
- Verify AI model switching
- Check file upload functionality
The extension supports both light and dark themes:
- Toggle using the theme button in the interface
- Preference is saved automatically
- Consistent across all extension pages
Add new AI models by modifying the model selector in `popup.js`:
```javascript // Add new model option const newModel = { id: "new-model-id", name: "New Model Name", icon: "assets/new-model-icon.png" }; ```
Feature | Description | Status |
---|---|---|
AI Test Generation | Generate unit tests using AI | β Active |
Multiple Models | Support for various AI models | β Active |
File Upload | Upload Go files for analysis | β Active |
Chat History | Track conversation history | β Active |
Theme Toggle | Light/Dark mode support | β Active |
Model Benchmarking | Compare model performance | β Active |
Timer Integration | Built-in productivity timer | β Active |
Export Functionality | Save generated tests to files | β Active |
- Local Storage: Chat history stored locally in Chrome
- API Keys: Stored securely in Chrome storage
- No Data Collection: Extension doesn't collect personal data
- Secure Communication: All API calls use HTTPS
Extension Not Loading
- Ensure Developer mode is enabled
- Check for JavaScript errors in DevTools
- Verify all files are present
API Errors
- Check your API key configuration
- Verify internet connection
- Ensure API service is available
File Upload Issues
- Check file size (should be reasonable)
- Ensure file is a valid text file
- Verify file permissions
Enable debug logging by opening DevTools:
- Right-click the extension popup
- Select "Inspect"
- Check Console for detailed logs
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
- Follow existing code style
- Add comments for complex logic
- Test with multiple AI models
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Groq: For providing fast AI inference
- Prism.js: For beautiful syntax highlighting
- Chrome Extensions API: For the platform
- Go Community: For inspiration and feedback
- Issues: Report bugs on GitHub Issues
- Discussions: Join our GitHub Discussions
- Email: Contact us at [email protected]
- Initial release
- Basic AI test generation
- Multiple model support
- File upload functionality
- Chat history
- Theme support
Made with β€οΈ for the Go community
Generate better tests, write better code.