4 ms·
I've found unit testing to work fine for Lambdas. The biggest difference between running as a Lambda and running locally is the entry point. With a Lambda you
by mywittyname 7y ago
I've found unit testing to work fine for Lambdas. The biggest difference between running as a Lambda and running locally is the entry point. With a Lambda you have an event payload that (usually) needs to be parsed and evaluated.
I'll typically write all the core functionality first, test it, then write the lambda_handler function.
- matthewbauer 7y agoBut how do you test lamba_handler then? Without a way to run lambdas locally, this sounds like a big black hole in your infrastructure.
- scarface74 7y agoYou call it just like you call any other function. Your handler takes in either a JSON payload and a context object or a deserialized object depending on the language. You call it from a separate console app, your test harness etc.
- mywittyname 7y agoYup. You can log into the AWS console and generate an example test message. Copy that into your unit/integration test and bob's your uncle.
- bmm6o 7y agoWe deploy to a test stack and run a full integration test of the code running in AWS. I believe it's also possible to self-host locally, but we never really looked into it.