
Answer-first summary for fast verification
Answer: Invoke the Lambda function with a predefined test event using the 'aws lambda invoke' command within the CI/CD process.
The correct answer is D. Using the 'aws lambda invoke' command with a test event during the CI/CD process is more aligned with unit testing principles. It allows the developer to simulate an SQS event and test the Lambda function's behavior in isolation without creating real SQS resources, which is essential for true unit testing. Other options, such as creating actual SQS queues (C) or CloudFormation templates (A), lean more towards integration tests rather than isolated unit tests.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
How should a developer unit test an AWS Lambda function designed to process messages from an SQS queue within a CI/CD pipeline?
A
Utilize an AWS CloudFormation template to instantiate an SQS queue and deploy the Lambda function, then test the function by invoking it within the CI/CD pipeline after stack creation.
B
Generate an SQS event for testing and simulate message consumption from the SQS queue during the CI/CD process.
C
Establish a test SQS queue, integrate it with the unit tests, and execute these tests as part of the CI/CD pipeline.
D
Invoke the Lambda function with a predefined test event using the 'aws lambda invoke' command within the CI/CD process.
No comments yet.