Skip to main content

AWS DVA-C02 Drill: CI/CD Pipeline Unit Testing - Integrating Tests Correctly

Jeff Taakey
Author
Jeff Taakey
21+ Year Enterprise Architect | AWS SAA/SAP & Multi-Cloud Expert.

Jeff’s Note
#

Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.

For DVA-C02 candidates, the confusion often lies in where and how to embed unit tests within automated pipelines. In production, this is about knowing exactly how to leverage CodeBuild phases to run tests efficiently before promoting builds downstream. Let’s drill down.

The Certification Drill (Simulated Question)
#

Scenario
#

NebulaSoft is a SaaS startup delivering an e-commerce platform through a CI/CD pipeline running on AWS. Developers must ensure that unit tests on the application code run automatically and successfully before build artifacts are promoted to integration testing. The company uses AWS CodePipeline combined with CodeBuild for compiling, testing, and packaging their software.

The Requirement:
#

How should the lead developer best integrate unit testing into the CI/CD workflow so tests run automatically during the pipeline execution before staging the build artifacts for testing?

The Options
#

  • A) Create a dedicated, separate AWS CodePipeline pipeline exclusively for running unit tests.
  • B) Update the AWS CodeBuild buildspec file to include a build phase dedicated to running unit tests.
  • C) Install and run the AWS CodeDeploy agent on EC2 instances to execute unit tests.
  • D) Create a dedicated testing branch in the source Git repository for the pipeline to trigger unit tests.

Google adsense
#

leave a comment:

Correct Answer
#

B

Quick Insight: The Developer Imperative
#

The best practice is embedding unit tests directly in CodeBuild’s lifecycle by configuring the buildspec.yml file. This tightly couples test execution with build phases, ensuring tests run every time without adding complexity or extra pipelines.
Running tests as a separate pipeline or relying on CodeDeploy agents breaks the CI/CD flow or adds overhead. Managing testing branches does not ensure the test execution phase happens smoothly in the pipeline.

Content Locked: The Expert Analysis
#

You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?


The Expert’s Analysis
#

Correct Answer
#

Option B

The Winning Logic
#

The AWS CodeBuild service uses a build specification file (buildspec.yml) that defines discrete phases in the build lifecycle, including install, pre_build, build, and post_build. Incorporating unit tests in the appropriate phase (often the build or post_build phase) allows tests to run automatically as part of every build execution initiated by CodePipeline.

  • This approach ensures cohesion within the pipeline: tests run before artifacts are staged or deployed.
  • It simplifies pipeline management by avoiding the need for multiple interconnected pipelines or external test runners.
  • The results of these unit tests directly impact pipeline success or failure, enabling early detection of defects.

The Trap (Distractor Analysis):
#

  • Why not A?
    Creating a separate CodePipeline just for unit tests adds needless complexity and overhead. It fragments the CI/CD flow and increases maintenance burden.

  • Why not C?
    AWS CodeDeploy agents run on EC2 instances to deploy applications, not to orchestrate unit tests. Using these agents for testing is a misuse of the service and breaks the pipeline design model.

  • Why not D?
    Having a dedicated git branch for testing source code does not automate test execution. The pipeline would still require configuration to run tests; branch separation alone doesn’t trigger unit tests.


The Technical Blueprint
#

# Example snippet from buildspec.yml to run unit tests using a common test framework (e.g., npm, pytest):

phases:
  install:
    commands:
      - echo Installing dependencies...
      - npm install
  build:
    commands:
      - echo Running unit tests...
      - npm test
  post_build:
    commands:
      - echo Unit tests completed.

The Comparative Analysis
#

Option API/Config Complexity Performance Impact Use Case Suitability
A High (multiple pipelines) Moderate Overkill for just running tests
B Low (buildspec.yml edit) Minimal Best practice for unit test integration
C Misuse of CodeDeploy Inefficient Invalid approach for this purpose
D Low (branch management) None Does not guarantee test execution

Real-World Application (Practitioner Insight)
#

Exam Rule
#

For the exam, always pick CodeBuild with buildspec modifications when you see “run unit tests in CI/CD pipelines”.

Real World
#

In real projects, some teams extend this by integrating test result reports (JUnit, Cobertura) and artifacts as part of the build to enhance visibility and quality gates.


(CTA) Stop Guessing, Start Mastering
#


Disclaimer

This is a study note based on simulated scenarios for the DVA-C02 exam.

The DevPro Network: Mission and Founder

A 21-Year Tech Leadership Journey

Jeff Taakey has driven complex systems for over two decades, serving in pivotal roles as an Architect, Technical Director, and startup Co-founder/CTO.

He holds both an MBA degree and a Computer Science Master's degree from an English-speaking university in Hong Kong. His expertise is further backed by multiple international certifications including TOGAF, PMP, ITIL, and AWS SAA.

His experience spans diverse sectors and includes leading large, multidisciplinary teams (up to 86 people). He has also served as a Development Team Lead while cooperating with global teams spanning North America, Europe, and Asia-Pacific. He has spearheaded the design of an industry cloud platform. This work was often conducted within global Fortune 500 environments like IBM, Citi and Panasonic.

Following a recent Master’s degree from an English-speaking university in Hong Kong, he launched this platform to share advanced, practical technical knowledge with the global developer community.


About This Site: AWS.CertDevPro.com


AWS.CertDevPro.com focuses exclusively on mastering the Amazon Web Services ecosystem. We transform raw practice questions into strategic Decision Matrices. Led by Jeff Taakey (MBA & 21-year veteran of IBM/Citi), we provide the exclusive SAA and SAP Master Packs designed to move your cloud expertise from certification-ready to project-ready.