A Lambda function will process messages from an Amazon SQS queue. The developer wants to include unit testing in the CI/CD pipeline for this function. What is an appropriate way to run unit tests for the function?
Choose an answer
Tap an option to check your answer.
Correct answer: Use the aws lambda invoke command in the CI/CD process with a test event to invoke the function for unit testing..
Why this is the answer
The aws lambda invoke command is the most appropriate way to run unit tests for a Lambda function in a CI/CD pipeline because it directly simulates how the function will be called with a specific event payload. This allows for isolated testing of the function's logic without requiring actual AWS resource deployments or complex infrastructure setup during the testing phase. The test event can be a JSON object mimicking an SQS message, allowing you to verify the function's processing logic. The other options are less suitable for unit testing. Deploying a full CloudFormation stack or dedicated SQS queues for unit tests introduces unnecessary complexity, increases test execution time, and moves beyond the scope of isolated unit testing into integration testing. Having the test framework consume messages from an SQS queue during CI/CD also blurs the line between unit and integration testing and requires more setup.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed