Contract Testing for AWS Lambdas

2019-07-19 00:53发布

Is there any way to do Contract testing for the AWS lambdas. Pact is being used for normal APIs, But I am trying to implement Contract Testing on AWS SAM. Is there any tool for this or Pact can be used with any modifications?

2条回答
戒情不戒烟
2楼-- · 2019-07-19 01:24

You can use the amazon-cli if you want to test it.

amazon-cli will help you to manually trigger your lamda via aws lambda invoke the command.

Please install amazon-cli at your local from this link.

After that you can invoke the amazon 1st lamda from your cli with aws lamda command. It comes with many options like you can pass payload (supposed to be pass from SNS in actual scenario).

Executing AWS Lamda from Amazon-CLI Command details description

Example command:

aws lambda invoke --function-name your_function_name --invocation-type RequestResponse outfile.txt --payload file:requestFile.txt

I hope it helps.

查看更多
仙女界的扛把子
3楼-- · 2019-07-19 01:43

Yes, you can use Pact to do contract testing with Lambda.

For example, Pact JS has support for asynchronous programming and has an example for Lambda using the serverless framework [1].

There is a good intro article [2] on the matter also.

查看更多
登录 后发表回答