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?
AA Lambda proxy integration whose function returns a hard-coded sample order
BAn HTTP API route with a mock integration that returns the sample
CA REST API method with a mock integration that returns the sample
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.
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?
ADefine staging in samconfig.toml and run sam deploy --config-env staging
BRun sam sync --watch against a stack named for staging
CRun sam deploy --guided for each release and type in the staging values
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.
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?
AAn archive on the bus, replayed to the new rule with yesterday's events
BThe TestEventPattern API, called with the pattern and each sample event
CPutEvents calls that send the samples to a test bus with the rule attached
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.
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.)
ASet the function to quote:${stageVariables.alias} and define alias in each stage
BAdd a canary setting on the prod stage that sends all of its traffic to the prod alias
CCreate a usage plan for each stage with its own throttling limits
DRun lambda add-permission so API Gateway may invoke each alias used by the stages
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.
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?
AAdd print statements and redeploy the function after each change
BTurn on AWS X-Ray active tracing for the function
CRun sam local invoke with a debug port (-d) and attach the IDE
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.
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?
Asam local start-api
Bsam local invoke
Csam local generate-event
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.
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?
AA coverage report for the JaCoCo file in the buildspec reports section
BAn artifacts entry that uploads the JaCoCo file to Amazon S3 after each build
CA CloudWatch Logs metric filter on the build log
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.
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?
AThe unit test generation command of Amazon Q Developer in the IDE chat
BA steering file that tells Kiro to update tests whenever a file under src/ is saved
CAn AWS CodeBuild project that runs the tests on every push
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.