Testing your serverless applicationsMocks1 min

Mocks are replacement objects that may simulate the behavior of cloud services for unit tests. Some mock frameworks are generic and others are designed specifically to mock AWS SDK’s. For example, moto is a framework for mocking the popular boto AWS SDK for Python. The aws-sdk-mock library provides a framework for mocking the AWS SDK for Javascript. These mock frameworks contain functions and return values similar to those contained within their SDK counterparts. Developers using other runtime languages may need to rely on more generic mocking frameworks. For example, Java developers may use Mockito or EasyMock and .NET developers may use Moq.

Local development can be fast with mock frameworks. Since mocks may provide substitute behavior for virtually any kind of object, mocking strategies may create broad coverage for a wide variety of services. However, mock frameworks may require a non-trivial amount of setup efforts. And mock frameworks cannot properly test IAM policies and quotas.


Created by:

Dan Fox
Dan FoxDan Fox is a Principal Specialist Solutions Architect at AWS. Dan works with customers to help them leverage serverless services to build scalable, fault-tolerant, high-performing, cost-effective applications.