GitLab Well Architected
Cookbook navigation
Prompts / Generate Unit Tests

Generate Unit Tests

TestingAutomationVerifyBeginner

Generate comprehensive unit tests covering happy paths, edge cases, and error conditions automatically.

For GitLab Duo

prompt

Generate unit tests for this function:

[PASTE FUNCTION]

Include tests for:
1. Happy path
2. Edge cases
3. Error conditions
4. Boundary values
5. Invalid inputs

Use the prompt

Include the function's intended behavior and your project's test conventions. The tests should check that behavior, not just repeat whatever the current implementation happens to return.