Unit Test Generation
This agent analyzes your source code and automatically generates a comprehensive unit test suite. It identifies nominal cases, edge cases, error cases and regression scenarios. Generated tests follow the chosen test framework best practices and aim for maximum coverage.
For who
Developers, tech leads and DevOps teams looking to improve their codebase test coverage.
Input
Code source Ă tester (fonction, classe ou module)
steps (3)
Code Analysis
inputStatic code analysis and test scenario identification
Test Generation
generationCreate tests covering all identified scenarios
Coverage Review
validationCoverage verification and test suite quality check
Output
Suite de tests unitaires complète avec matrice de couverture
Example
Input
function calculateDiscount(price, quantity, couponCode) {
if (price <= 0) throw new Error("Invalid price");
let discount = 0;
if (quantity >= 10) discount += 0.1;
if (couponCode === "VIP") discount += 0.2;
return price * (1 - discount);
}Output
describe("calculateDiscount", () => {
it("should apply no discount for small quantity", () => {
expect(calculateDiscount(100, 1, "")).toBe(100);
});
it("should apply 10% for quantity >= 10", () => {
expect(calculateDiscount(100, 10, "")).toBe(90);
});
it("should throw for negative price", () => {
expect(() => calculateDiscount(-1, 1, "")).toThrow();
});
});
Coverage: 95% | Score: 88/100Customization
| Parameter | Description | Default |
|---|---|---|
Technical Notes
Related Prompts
Content ROI Measurement Framework
Setting up a content measurement system
Mock Oral Exam Simulation
Oral Exam Practice
Validate Component Accessibility
Make components accessible to users with disabilities
Turn Your Meeting into an Actionable Action Plan for Agencies
Prompt to generate a structured action plan from meeting minutes, with prioritization, responsibilities and KPIs, tailored for B2B communication agencies.