مولد اختبارات الوحدة

لماذا تهم هذه المطالبة
AI-generated tests catch edge cases developers often miss. The structured prompt ensures comprehensive coverage beyond just the happy path.
فيم نستخدمها
Testing
المطالبة
Write unit tests for the following function. Cover: happy path, edge cases (empty input, null, boundary values), error conditions, and type edge cases. Use the testing framework appropriate for the language. Each test should have a descriptive name that explains what it tests.
النتيجة
```typescript describe('calculateDiscount', () => { it('applies 10% discount for orders over $100', () => { expect(calculateDiscount(150)).toBe(135); }); it('returns original price for orders at exactly $100', () => { expect(calculateDiscount(100)).toBe(100); }); it('throws for negative amounts', () => { expect(() => calculateDiscount(-1)).toThrow('Invalid amount'); }); }); ```
AI-generated tests catch edge cases developers often miss. The structured prompt ensures comprehensive coverage beyond just the happy path.
This prompt demonstrates a structured approach to testing, producing consistent, high-quality results that can be iterated upon.