Unit Testing with SAM Quiz

5 questions Pass: 70% +25 pts (50 with Pro)

Quiz covering Application Development

What you'll be asked

  1. Which command is used to locally invoke a Lambda function defined in your AWS SAM template for testing purposes?
  2. When unit testing a Lambda function that uses the AWS SDK, what is the best practice for handling service calls (e.g., DynamoDB or S3)?
  3. You want to test how your Lambda function handles an API Gateway event. Which SAM CLI command should you use to simulate an API endpoint locally?
  4. Why is it recommended to separate your business logic from the Lambda handler function when writing unit tests?
  5. You are debugging a local SAM function, but the environment variables defined in your template.yaml are not being picked up correctly. Which flag should be used with 'sam local invoke' to ensure local environment files are loaded?

Answers and explanations come after you submit.