DVA-C02 · Question #144
DVA-C02 Question #144: Real Exam Question with Answer & Explanation
The correct answer is C: Create an SQS queue for tests. Use this SQS queue in the application's unit test. Run the unit. Unit testing is a type of testing that verifies the correctness of individual units of source code, typically functions or methods. When unit testing a Lambda function that interacts with Amazon SQS, you can create a separate test SQS queue that the Lambda function interacts with
Question
A developer is creating an AWS Lambda function. The Lambda function will consume messages from an Amazon Simple Queue Service (Amazon SQS) queue. The developer wants to integrate unit testing as part of the function's continuous integration and continuous delivery (CI/CD) process. How can the developer unit test the function?
Options
- ACreate an AWS CloudFormation template that creates an SQS queue and deploys the Lambda
- BCreate an SQS event for tests. Use a test that consumes messages from the SQS queue during
- CCreate an SQS queue for tests. Use this SQS queue in the application's unit test. Run the unit
- DUse the aws lambda invoke command with a test event during the CIICD process.
Explanation
Unit testing is a type of testing that verifies the correctness of individual units of source code, typically functions or methods. When unit testing a Lambda function that interacts with Amazon SQS, you can create a separate test SQS queue that the Lambda function interacts with during testing. You would then validate the behavior of the function based on its interactions with the test queue. This approach isolates the function's behavior from the rest of the system, which is a key principle of unit testing. https://aws.amazon.com/blogs/devops/unit-testing-aws-lambda-with-python-and-mock-aws-
Community Discussion
No community discussion yet for this question.