Skip to content

DVA-C03 · Domain 3: Testing and Deployment · 22% of the exam

Task 3.2: Implement and automate application testing in AWS environments.

Testing before and during release: tests with AWS SAM, the CDK and CloudFormation, mock APIs for missing dependencies, JSON test events for functions and APIs, test environments with Lambda aliases, image tags, Amplify branches and API stages, and AI tools that write and run tests.

Study it

  • API Gateway stages, stage URLs, endpoints and custom domains

    Lesson coming

  • AWS SAM and the CDK: local testing, test events and infrastructure tests

    Lesson coming

  • Mocks, integration tests and test environments: aliases, image tags, Amplify branches

    Lesson coming

  • AI tools that write and run tests

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the AWS documentation page that proves it.

Question 1 · choose 1

A front-end team needs to start testing against GET /orders/{id}, but the backend service that will serve it has not been built. Both teams have agreed on the response format. The developer wants a deployed API endpoint that returns a fixed sample order now, without deploying any backend code. What should the developer configure?

  1. AA Lambda proxy integration whose function returns a hard-coded sample order
  2. BAn HTTP API route with a mock integration that returns the sample
  3. CA REST API method with a mock integration that returns the sample
  4. DAPI caching on the stage, loaded once with the sample order
Show the answer and why
  • AA Lambda proxy integration whose function returns a hard-coded sample order

    Incorrect

    This would work, but it deploys backend code, the function, which the requirement rules out.

  • BAn HTTP API route with a mock integration that returns the sample

    Incorrect

    Mock integrations are a REST API feature. HTTP APIs do not support them.

  • CA REST API method with a mock integration that returns the sample

    Correct

    A mock integration lets API Gateway generate the response itself, with no backend, which unblocks teams that depend on the API.

  • DAPI caching on the stage, loaded once with the sample order

    Incorrect

    API caching stores responses that come back from the endpoint for a TTL, so there must be an endpoint to call in the first place.

REST API mock integrations return responses defined in API Gateway, which is a common way to test clients before the backend exists.

Question 2 · choose 1

An AWS SAM application is deployed to a dev stack with sam deploy. The developer must now deploy the same template to a separate staging stack with its own stack name and parameter values, such as a larger memory size. Developers and the release pipeline must be able to repeat the staging deployment with one short command. What should the developer do?

  1. ADefine staging in samconfig.toml and run sam deploy --config-env staging
  2. BRun sam sync --watch against a stack named for staging
  3. CRun sam deploy --guided for each release and type in the staging values
  4. DRun sam local invoke with a file of staging environment variables
Show the answer and why
  • ADefine staging in samconfig.toml and run sam deploy --config-env staging

    Correct

    The configuration file holds named environments with their own values, such as the stack name and parameter overrides, and --config-env picks which environment's values sam deploy uses.

  • BRun sam sync --watch against a stack named for staging

    Incorrect

    sam sync is a rapid workflow recommended for development environments; for other environments AWS recommends sam deploy or a CI/CD pipeline.

  • CRun sam deploy --guided for each release and type in the staging values

    Incorrect

    --guided walks a person through interactive prompts. A pipeline cannot answer them, and retyping values on every release is error-prone.

  • DRun sam local invoke with a file of staging environment variables

    Incorrect

    sam local invoke runs one invocation of a function locally. It does not deploy anything to AWS.

samconfig.toml environments keep per-environment deploy settings, so the same template deploys to dev, staging or prod with --config-env.

Question 3 · choose 1

A developer has written an event pattern for a new Amazon EventBridge rule and has a few sample event JSON documents: some should match and some should not. Before creating the rule, the developer wants a quick automated check of which samples the pattern matches, without sending any event to an event bus or invoking any target. What should the developer use?

  1. AAn archive on the bus, replayed to the new rule with yesterday's events
  2. BThe TestEventPattern API, called with the pattern and each sample event
  3. CPutEvents calls that send the samples to a test bus with the rule attached
  4. Dsam local invoke with each sample event passed to the target function
Show the answer and why
  • AAn archive on the bus, replayed to the new rule with yesterday's events

    Incorrect

    A replay resends archived events to the event bus, where matching rules deliver them to their targets, and the rule must already exist.

  • BThe TestEventPattern API, called with the pattern and each sample event

    Correct

    TestEventPattern tests whether a given event pattern matches a provided event and returns a true or false result, without touching any bus.

  • CPutEvents calls that send the samples to a test bus with the rule attached

    Incorrect

    PutEvents sends events to EventBridge so that rules can match them. That sends events to a bus, which the developer wants to avoid.

  • Dsam local invoke with each sample event passed to the target function

    Incorrect

    sam local invoke runs a function locally with an event. It tests the function's code, not whether EventBridge would match the event.

TestEventPattern is the unit test for an event pattern; it checks matching logic without events reaching a bus or a target.

Question 4 · choose 2

A REST API in Amazon API Gateway has a dev stage and a prod stage. Its GET /quote method uses a Lambda integration. Calls through the dev stage must invoke the dev alias of the quote function, and calls through the prod stage must invoke the prod alias, with one method definition shared by both stages. Which TWO steps should the developer take? (Choose TWO.)

  1. ASet the function to quote:${stageVariables.alias} and define alias in each stage
  2. BAdd a canary setting on the prod stage that sends all of its traffic to the prod alias
  3. CCreate a usage plan for each stage with its own throttling limits
  4. DRun lambda add-permission so API Gateway may invoke each alias used by the stages
  5. ETurn on API caching in each stage so that each alias has its own cache
Show the answer and why
  • ASet the function to quote:${stageVariables.alias} and define alias in each stage

    Correct

    A stage variable can supply the function name, including an alias such as quote:prod, so each stage resolves the same method to its own alias.

  • BAdd a canary setting on the prod stage that sends all of its traffic to the prod alias

    Incorrect

    A canary splits one stage's traffic at random between a production deployment and a canary deployment. It does not map stages to aliases.

  • CCreate a usage plan for each stage with its own throttling limits

    Incorrect

    Usage plans give clients access to stages with throttling and quotas. They do not decide which backend a method calls.

  • DRun lambda add-permission so API Gateway may invoke each alias used by the stages

    Correct

    When a stage variable names the function, the permissions on the Lambda function must be configured manually, for example with add-permission.

  • ETurn on API caching in each stage so that each alias has its own cache

    Incorrect

    Caching stores endpoint responses for a TTL. It does not choose which function or alias the integration calls.

Stage variables make one API definition behave per environment; when they name a Lambda function or alias, API Gateway also needs an invoke permission on each target.

Question 5 · choose 1

A developer is chasing a logic bug in an AWS Lambda function of an AWS SAM application and wants to set breakpoints, inspect variables and step through the code in an IDE on the laptop, using a sample event. What should the developer do?

  1. AAdd print statements and redeploy the function after each change
  2. BTurn on AWS X-Ray active tracing for the function
  3. CRun sam local invoke with a debug port (-d) and attach the IDE
  4. DRun sam sync --watch and debug the function in the console
Show the answer and why
  • AAdd print statements and redeploy the function after each change

    Incorrect

    This works slowly through the cloud and gives no breakpoints or step-through debugging.

  • BTurn on AWS X-Ray active tracing for the function

    Incorrect

    Tracing records timing of requests in the cloud; it does not stop at breakpoints in the code.

  • CRun sam local invoke with a debug port (-d) and attach the IDE

    Correct

    sam local invoke and start-api accept --debug-port (-d) so that a debugger can attach for local step-through debugging.

  • DRun sam sync --watch and debug the function in the console

    Incorrect

    sam sync updates the cloud copy quickly but does not provide a local step-through debugger.

AWS SAM supports local step-through debugging with debug ports and IDE toolkits.

Question 6 · choose 1

An integration test suite calls AWS Lambda functions with the AWS SDK's Invoke operation. The developer wants to run the same suite on a laptop against the functions defined in an AWS SAM template, by pointing the SDK client at a local endpoint. Which command provides that endpoint?

  1. Asam local start-api
  2. Bsam local invoke
  3. Csam local generate-event
  4. Dsam local start-lambda
Show the answer and why
  • Asam local start-api

    Incorrect

    start-api serves the API's HTTP routes, not the Lambda Invoke API that the SDK calls.

  • Bsam local invoke

    Incorrect

    local invoke runs one function once from the command line; it does not keep an endpoint running for SDK calls.

  • Csam local generate-event

    Incorrect

    generate-event creates sample event payloads; it does not run any function.

  • Dsam local start-lambda

    Correct

    start-lambda starts a local endpoint that emulates AWS Lambda, so SDK Invoke calls can run against local functions.

Use start-lambda for SDK or CLI invocations and start-api for HTTP routes when testing locally.

Question 7 · choose 1

A Java project's tests run in AWS CodeBuild and write a JaCoCo XML coverage file. The team wants line and branch coverage for each build shown in CodeBuild, so that coverage drops are visible without another tool. What should the developer configure?

  1. AA coverage report for the JaCoCo file in the buildspec reports section
  2. BAn artifacts entry that uploads the JaCoCo file to Amazon S3 after each build
  3. CA CloudWatch Logs metric filter on the build log
  4. DA local cache entry for the JaCoCo file
Show the answer and why
  • AA coverage report for the JaCoCo file in the buildspec reports section

    Correct

    CodeBuild can generate code coverage reports from formats such as JaCoCo XML, including line and branch coverage.

  • BAn artifacts entry that uploads the JaCoCo file to Amazon S3 after each build

    Incorrect

    Artifacts store files; CodeBuild does not show coverage from them.

  • CA CloudWatch Logs metric filter on the build log

    Incorrect

    A metric filter needs coverage values printed as log text and builds a separate view, which the team wants to avoid.

  • DA local cache entry for the JaCoCo file

    Incorrect

    Caching reuses files between builds; it does not create reports.

CodeBuild report groups cover both test reports and code coverage reports.

Question 8 · choose 1

A team writes its services in Kiro. Developers often change a module and forget to update and run its unit tests until the pipeline fails. The team wants Kiro to update the matching test file and run the unit tests automatically every time a source file under src/ is saved, without anyone having to ask for it. What should the team set up?

  1. AThe unit test generation command of Amazon Q Developer in the IDE chat
  2. BA steering file that tells Kiro to update tests whenever a file under src/ is saved
  3. CAn AWS CodeBuild project that runs the tests on every push
  4. DA Kiro agent hook that runs on file saves under src/
Show the answer and why
  • AThe unit test generation command of Amazon Q Developer in the IDE chat

    Incorrect

    A chat command runs only when a developer asks for it, and AWS ends support for the Amazon Q Developer IDE plugins on April 30, 2027.

  • BA steering file that tells Kiro to update tests whenever a file under src/ is saved

    Incorrect

    Steering files give Kiro persistent knowledge of a project's conventions. They guide the work Kiro is asked to do but do not start any action when a file is saved.

  • CAn AWS CodeBuild project that runs the tests on every push

    Incorrect

    A build on push runs the existing tests after the code leaves the laptop. It neither runs on each save nor updates the test files.

  • DA Kiro agent hook that runs on file saves under src/

    Correct

    Agent hooks are automated triggers that run predefined agent actions when events such as saving, creating or deleting files occur, so routine tasks happen without a manual request.

Kiro agent hooks automate repetitive work, such as updating and running tests, by triggering predefined agent actions on file events.

Practice domain 3 →Practice all domains →