Q51 — AWS DOP-C02 Ch.3
Question 51 of 100 | ← Chapter 3
A software team is using AWS CodePipeline to automate the release pipeline for a Java application. The pipeline consists of source, build, and deploy stages. Each stage contains one action with a runOrder value of 1. The team wants to incorporate unit testing into the existing release pipeline. The team needs a solution that deploys code only if unit tests pass. Which solution meets these requirements?
- A. Modify the build stage. Add a test action with runOrder value 1. Use AWS CodeDeploy as the action provider to run unit tests.
- B. Modify the build stage. Add a test action with runOrder value 2. Use AWS CodeBuild as the action provider to run unit tests. ✓
- C. Modify the deploy stage. Add a test action with runOrder value 1. Use AWS CodeDeploy as the action provider to run unit tests.
- D. Modify the deploy stage. Add a test action with runOrder value 2. Use AWS CodeBuild as the action provider to run unit tests.
Correct Answer: B. Modify the build stage. Add a test action with runOrder value 2. Use AWS CodeBuild as the action provider to run unit tests.
Explanation
In AWS CodePipeline, stage action ordering is controlled by `runOrder`; actions with smaller `runOrder` values execute first within the same stage. The original build stage already has an action with `runOrder=1`. To ensure unit tests execute after the build and before deployment, the new test action must have a higher `runOrder` (e.g., `runOrder=2`) in the same build stage. AWS CodeBuild supports custom build commands and is designed to run unit tests. Option B correctly places the test action in the build stage with `runOrder=2`, ensuring tests run after the initial build action and before proceeding to deployment. Option A’s `runOrder=1` would cause parallel execution, violating dependency order; Options C and D place testing in the deploy stage, which contradicts the principle that testing should occur prior to deployment.