Serverless Testing - AWS Lambda

Let's start with what is Serverless Framework?

Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to build more logic, faster.

The Serverless Framework helps you develop and deploy your AWS Lambda functions, along with the AWS infrastructure resources they require. It's a CLI that offers structure, automation and best practices out-of-the-box, allowing you to focus on building sophisticated, event-driven, serverless architectures, comprised of Functions and Events.
  • It manages your code as well as your infrastructure
  • It supports multiple languages (Node.js, Python, Java, and more)
AWS Lambda is a compute service that lets you run code without provisioning or managing servers. You can also build serverless applications composed of functions that are triggered by events and automatically deploy them using AWS CodePipeline and AWS CodeBuild.

The Mantra is: Build auto-scaling, pay-per-execution, event-driven apps on AWS Lambda

While the Serverless Architecture introduces a lot of simplicity when it comes to serving business logic, some of its characteristics present challenges for testing. They are:
  1. The Serverless Architecture is an integration of separate, distributed services, which must be tested both independently, and together.
  2. The Serverless Architecture is dependent on internet/cloud services, which are hard to emulate locally.
  3. The Serverless Architecture can feature event-driven, asynchronous workflows, which are hard to emulate entirely.

To get through these challenges, and to keep the test pyramid in mind, keep the following principles in mind:
  1. Write your business logic so that it is separate from your FaaS provider (e.g., AWS Lambda), to keep it provider-independent, reusable and more easily testable.
  2. When your business logic is written separately from the FaaS provider, you can write traditional Unit Tests to ensure it is working properly.
  3. Write Integration Tests to verify integrations with other services are working correctly.
From an AWS book the three levels of testing for a serverless architecture:
  • Acceptance – does the whole system work?
  • Integration – does our code work against code we can’t change?
  • Unit – do our objects do the right thing, are they easy to work with?
  • A Lambda function is ultimately a piece of code that AWS invokes on your behalf when some input event occurs. To test that it integrates correctly with downstream systems you can invoke the function from your chosen test framework



  1. This is a very nice article. thank you for publishing this. i can understand this easily. AWS Online Training

  2. nice post! Thanks for delivering a good stuff related to DevOps, Explination is good, nice Article
    anyone want to learn advance devops tools or devops online training
    DevOps Online Training
    DevOps Training institute in Ameerpet

  3. Thanks for sharing such a beautiful information with us. I hope you will share more info about it.
    Plese keep sharing.Best Toshiba service center in Kukatpally


Post a Comment

Popular posts from this blog

Trim / Remove spaces in Xpath?

Complete list of Serenity properties

XPATH for IE / internet explorer