Skill 3.2.5
Use AWS AI tools to generate tests and automate repetitive testing workflows (for example, automated test execution, test result analysis, regression testing automation, test coverage).
Key Concepts
Generating tests works best from a specification. In a Kiro spec, each acceptance criterion in requirements.md becomes one or more test cases, and the task list in tasks.md includes writing tests alongside the code. Kiro can also generate property-based tests, which check a property that must always hold, such as "applying a discount never produces a negative total", against many generated inputs rather than a few hand-picked examples. For existing code, the developer asks the agent to add unit tests for a module, with mocks for AWS calls, and to cover the error paths.
Automated test execution uses agent hooks. A PostFileSave hook runs the unit tests for the changed module, and a Stop hook runs the full suite when the agent finishes a task, so failures appear immediately. When tests fail, the agent can analyse the output, explain the cause and propose a fix for the developer to review.
Regression testing protects behaviour that must not change. A Kiro bugfix spec records the expected behaviour and the unchanged behaviour, and the tests generated from it prevent the bug from returning. In the pipeline, AWS CodeBuild runs the whole suite on every commit, publishes test reports and code coverage reports (for example in JaCoCo, Cobertura or LCOV format), and fails the build when a test fails or coverage drops below a threshold. The Kiro CLI can run in headless mode in the same build to review coverage gaps or summarise failures.
Generated tests have known weaknesses. A test written from the current code may assert the current, incorrect behaviour; tests may mock so much that they test nothing; and they may miss edge cases the model did not consider. Reviewing assertions against the requirements, checking that a deliberately broken implementation makes the tests fail, and tracking coverage of requirements as well as lines keep AI-generated tests trustworthy.