Integration points testing checklist – Testing Serverless Applications

Integration points testing checklist

For each integration point you should capture the failure modes for the categories listed in Table 7-1 and decide whether to cover them with tests.

Table 7-1. Integration points testing checklist

Remember not to couple decoupled components in your tests. Whenever possible, test the source and target of an integration point separately.

Unit Testing Business Logic in Lambda Functions

The business logic of a serverless application is written and executed in Lambda functions. The bulk of business logic testing can thus be achieved through unit tests that assert the various operations of a Lambda function. You will usually test the individual operations of a Lambda function in isolation rather than testing the function as a whole, by calling the handler method, for instance.

Making your Lambda functions testable will usually involve abstracting and isolating your business logic and sharing the methods with test files. In this simple example of a testable Node.js Lambda function, the greeting method can easily be called and verified:

export const greeting = (name) => {

return `hello ${name}`;

}

export const handler = async (event) => {

return greeting(event.name)

};

The corresponding unit test can import the abstracted method and verify it in isolation:

import { greeting } from “./”;

test(“Should say hello world”, () => {

const actual = greeting(“world”);

const expected = “hello world”;

expect(actual).toEqual(expected);

});

Leave a Reply

Your email address will not be published. Required fields are marked *