🧪 AI Test Case GeneratorEnterprise-grade AI-powered test case generator for Python (pytest) and Salesforce Apex. Designed for production systems with cross-file dependency awareness, framework intelligence, governor limits compliance, and self-healing test validation. 🌟 Key Features🐍 Python (pytest) Intelligence
☁️ Salesforce Apex Enterprise Engine
🏢 Enterprise & Security Ready
🚀 Quick Start1. Build and Compile
2. Configure API Keys in VS CodeOpen the Command Palette (
3. Generate TestsIn Python (
|
| Setting | Default | Description |
|---|---|---|
testgen.pythonPath |
python |
Path to Python interpreter |
testgen.apiBaseUrl |
https://generativelanguage.googleapis.com/v1beta/openai |
OpenAI-compatible endpoint |
testgen.model |
gemini-2.5-flash |
AI model name |
testgen.outputFolder |
generated_tests |
Folder name where tests are saved |
testgen.validateTests |
true |
Validate test syntax & structure before saving |
testgen.autoRunTests |
false |
Automatically execute pytest after generation (Python) |
Workspace Configuration (.testgenrc.json)
Create .testgenrc.json in your workspace root (or run TestGen: Initialize Project Config):
{
"include": ["**/*.py", "**/*.cls"],
"exclude": [
"**/tests/**",
"**/test_*.py",
"**/*Test.cls",
"**/generated_tests/**",
"**/node_modules/**",
"**/venv/**"
],
"testFramework": "pytest",
"outputDir": "generated_tests",
"model": "gemini-2.5-flash",
"maxTestsPerFunction": 15,
"skipPrivate": true,
"rateLimitDelay": 2,
"validateBeforeSave": true,
"runAfterGenerate": false
}
💻 CLI Usage (Without VS Code)
You can run both engines independently in CI/CD pipelines, headless environments, or scripts.
1. Python Generation (engine/main.py)
# Generate for entire Python file
python engine/main.py --file src/utils.py --api-key YOUR_KEY
# Generate for specific function with pytest execution
python engine/main.py --file src/utils.py --function calculate_tax --api-key YOUR_KEY --run
# Dual key fallback
python engine/main.py --file src/utils.py --api-key KEY1 --fallback-key KEY2
2. Salesforce Apex Generation (engine/apex_main.py)
# Generate Apex test class for entire .cls file
python engine/apex_main.py --file force-app/main/default/classes/AccountService.cls --api-key YOUR_KEY
# Generate tests for a specific Apex method
python engine/apex_main.py --file AccountService.cls --method getAccountsByIndustry --api-key YOUR_KEY
# JSON output for CI/CD integration
python engine/apex_main.py --file AccountService.cls --api-key YOUR_KEY --json
3. Project-Wide Python Scanner (engine/scanner.py)
# Discover untested functions across workspace
python engine/scanner.py . --dry-run
# Batch generate tests for all untested functions
python engine/scanner.py . --api-key YOUR_KEY
4. Apex Validator (engine/apex_validator.py)
# Validate Apex test syntax, structure, and best practices
python engine/apex_validator.py generated_tests/AccountServiceTest.cls
📦 Packaging & Sharing the Extension (.vsix)
To share the extension with your team or test it on another machine:
1. Package into a .vsix installer
Run:
npx @vscode/vsce package
This generates a file named ai-testgen-0.5.0.vsix in your root project folder.
2. Share with Team Members
Send the ai-testgen-0.5.0.vsix file via email, Slack, Google Drive, or your internal repository.
3. Install on Any Machine
In VS Code:
- Open the Extensions view (
Ctrl+Shift+X/Cmd+Shift+X). - Click the
...(Views and More Actions) menu in the top-right corner of the Extensions pane. - Select Install from VSIX...
- Pick the
ai-testgen-0.5.0.vsixfile. - Set your API Key using TestGen: Set Primary API Key from the Command Palette (
Ctrl+Shift+P).
Alternatively via terminal:
code --install-extension ai-testgen-0.5.0.vsix
🧪 Running the Test Suite
Run the full automated test suite (150 tests):
python -m pytest tests/
Check coverage:
python -m pytest --cov=engine tests/
🏛️ Architecture
┌────────────────────────────────────────────────────────┐
│ VS Code Extension (TypeScript) │
│ • CodeLens for Python (defs) & Apex (.cls methods) │
│ • Context menus & Command Palette workflows │
│ • SecretStorage secure credential management │
└──────────────┬─────────────────────────┬───────────────┘
│ spawns │ spawns
▼ ▼
┌───────────────────────────────┐ ┌────────────────────────────────┐
│ Python Engine │ │ Salesforce Apex Engine │
│ • analyzer.py (AST) │ │ • apex_analyzer.py (Regex) │
│ • generator.py (AI + Retry) │ │ • apex_generator.py (Governor)│
│ • validator.py (AST + Pytest)│ │ • apex_validator.py (Best Pr) │
│ • scanner.py (Workspace Scan)│ │ • apex_main.py (Orchestrator) │
│ • main.py (Orchestration) │ └────────────────┬───────────────┘
└──────────────┬────────────────┘ │
│ │ writes
▼ ▼
┌───────────────────────────┐ ┌───────────────────────────┐
│ generated_tests/ │ │ generated_tests/ │
│ ├── conftest.py │ │ └── AccountServiceTest.cls│
│ └── test_func.py │ │ (200+ bulk, mocks) │
└───────────────────────────┘ └───────────────────────────┘
📄 License
MIT