3.3.6 Amazon Q Developer for Automated Tests

Use Amazon Q Developer to Generate Automated Tests

Capabilities

FeatureMô tả
Unit test generationGenerate tests from existing code
Test coverageIdentify untested code paths
Mock generationCreate mocks for dependencies
Edge casesSuggest edge case test scenarios

How to Use

1. Select function/method in IDE
2. Ask Q Developer: "Generate unit tests for this function"
3. Review generated tests
4. Customize assertions and edge cases
5. Run tests

Example Prompt

"Generate pytest unit tests for this Lambda handler that:
- Tests successful order creation
- Tests validation errors
- Tests DynamoDB exceptions
- Mocks boto3 DynamoDB calls"

Best Practices

  • Review generated tests — don’t blindly trust
  • Add business-specific assertions
  • Ensure edge cases are covered
  • Use as starting point, not final tests

Exam Tip: Amazon Q Developer can generate unit tests from code. Review and customize generated tests. New topic in DVA-C02 exam.