AWS Certified Developer – Associate / Question #969 of 557

Question #969

A developer is configuring an AWS CodePipeline to automate the build and deployment process. The pipeline must produce a detailed test report after each build phase. Which approach ensures the test report is generated correctly?

A

Set up an AWS CodeBuild project that includes test commands. Specify the report generation settings in the buildspec.yml file.

B

Use AWS CodeDeploy to execute test scripts during deployment. Define the report parameters in the appspec.yml file.

C

Install a custom testing framework on an Amazon EC2 instance managed by AWS Systems Manager and run tests via SSM documents.

D

Configure AWS CodeCommit to store test scripts and generate reports using Git hooks.

Explanation

Answer A is correct because AWS CodeBuild natively supports generating test reports via the buildspec.yml file. Developers can include test commands (e.g., unit tests) in the build phase and configure the 'reports' section in the buildspec.yml to specify the report format and location. This ensures the test report is automatically generated, stored in Amazon S3, and displayed in the AWS CodeBuild console.

Other options are incorrect because:
- B: AWS CodeDeploy's appspec.yml focuses on deployment hooks, not build/test reporting.
- C: Using EC2 with SSM adds unnecessary complexity and bypasses CodeBuild's built-in reporting features.
- D: CodeCommit/Git hooks are for repository events, not build/test phases.

Key Points:
1. CodeBuild's buildspec.yml is the standard way to define build/test commands and reports.
2. Test reports in CodeBuild are stored in S3 and visible in the AWS console.
3. CodePipeline stages (e.g., Build) use CodeBuild for testing and reporting.

Answer

The correct answer is: A