https://github.com/achanandhi-m/unit-test-generator
Automagically generate Google Test unit tests for your C++ code with AI! This tool uses Ollama's AI models to create comprehensive test cases that actually compile and pass with good coverage.
https://github.com/achanandhi-m/unit-test-generator
cpp golang ollama qwen2-5
Last synced: 3 months ago
JSON representation
Automagically generate Google Test unit tests for your C++ code with AI! This tool uses Ollama's AI models to create comprehensive test cases that actually compile and pass with good coverage.
- Host: GitHub
- URL: https://github.com/achanandhi-m/unit-test-generator
- Owner: Achanandhi-M
- Created: 2025-06-28T07:31:07.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-06-28T07:47:36.000Z (3 months ago)
- Last Synced: 2025-06-28T08:30:42.169Z (3 months ago)
- Topics: cpp, golang, ollama, qwen2-5
- Language: Go
- Homepage:
- Size: 0 Bytes
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Unit Test Generator
A tool that automatically generates unit tests for C++ code using Ollama's AI models and Google Test framework.
## Features
- Generates Google Test unit tests for C++ code
- Validates generated tests by compiling and running them
- Measures code coverage and enforces minimum thresholds
- Supports both header (.h) and implementation (.cpp) files
- Works with Ollama's local AI models## Prerequisites
- [Go](https://golang.org/dl/) (1.20+ recommended)
- [Ollama](https://ollama.ai/) installed and running
- C++ compiler (g++ or clang++)
- Google Test installed
- gcov for coverage analysis## Installation
1. Clone this repository:
```bash
git clone https://github.com/yourusername/unit-test-generator.git
cd unit-test-generator
```2. Install dependencies:
```bash
go mod download
```3. Pull the required Ollama model:
```bash
ollama pull qwen2.5-coder:7b
```## Usage
1. Place your C++ code in the `codebase` directory (both .h and .cpp files)
2. Run the generator:
```bash
go run main.go
```3. Generated tests will be saved in the `tests` directory
## Configuration
### Environment Variables
- `OLLAMA_HOST`: URL of Ollama server (default: `http://localhost:11434`)
### Directory Structure
```
unit-test-generator/
├── codebase/ # Your C++ source files go here
├── tests/ # Generated unit tests will be saved here
├── go.mod
├── go.sum
└── main.go # Main application code
```## Made with ❤️ and too much debugging
## Demo
https://github.com/user-attachments/assets/404a1573-6b6d-48e7-a7de-9e7c605aa3c2