Automatically generate, run, and evaluate Google Test unit tests for your C++ codebase using Github Models
Use these models for best results
- https://github.com/marketplace/models/azure-openai/gpt-4-1
- https://github.com/marketplace/models/azure-openai/gpt-4-1-mini
- https://github.com/marketplace/models/azure-openai/gpt-4-1-nano
- Scans and parses your C++ codebase
- Uses a Github Hosted LLM to generate unit tests
- Builds the project using
CMake - Resolves build issues using LLM
- Compiles and runs Google Test test cases
- Measures test coverage with
gcov - Removes failing test cases automatically via LLM feedback
unit-test-generator
├── codebase => C++ source files to test
├── tests => Generated test files (Automatically generated)
├── build => CMake build output (Automatically Generated)
├── src => Node.js test generator logic
- g++
- CMake >= 3.10
- Google Test
gtest
- Node.js >= 16
js-yaml,glob,dotenv, etc. (runnpm install)
mkdir unit-test-generator
cd unit-test-generatormkdir codebasemv <path to your c++ project> ./codebasegit clone https://github.com/HarshitBamotra/cpp-unit-test-generator.git srccd srcnpm installSample .env file
ENDPOINT = "https://models.github.ai/inference"
MODEL_NAME = "openai/gpt-4.1-mini"
LLM_ACCESS_TOKEN = <your github PAT token> (make sure to provide read access to models while generating PAT token)npm start- Make app run for generalized cpp project path (currently only works for ../codebase)
- Make this into a CLI
- Add more language generators




