AWS Certified Developer – Associate (DVA-C02) — Question 488
A company runs continuous integration/continuous delivery (CI/CD) pipelines for its application on AWS CodePipeline. A developer must write unit tests and run them as part of the pipelines before staging the artifacts for testing.
How should the developer incorporate unit tests as part of CI/CD pipelines?
Answer options
- A. Create a separate CodePipeline pipeline to run unit tests.
- B. Update the AWS CodeBuild build specification to include a phase for running unit tests.
- C. Install the AWS CodeDeploy agent on an Amazon EC2 instance to run unit tests.
- D. Create a testing branch in a git repository for the pipelines to run unit tests.
Correct answer: B
Explanation
AWS CodeBuild utilizes a build specification (buildspec) file to define build commands, making it the standard and most efficient location to define a phase for running unit tests. Using a separate pipeline adds unnecessary complexity, and AWS CodeDeploy is designed for software deployment rather than running unit tests during the build stage. Managing tests purely via Git branches does not configure how the pipeline actually runs the test commands.