Testing and static code analysis

Testing is an essential part of development, it is must when we develop any application. It helps to mitigate most of the bugs and performance issues before going to production. There are many types of testing involved in application development. These include, unit testing, integration testing and performance testing. They integrated into different stages of the environment deployment. Unit testing is integrated in the development stage. 

The serverless handler should always be a thin layer that uses modules out of your code library. And modules should be well-covered with unit tests; then testing of the serverless application will be easy during the integration tests.

We should try to run unit tests and integration test the modules and function locally, this will help to run the tests faster, and find issues in code base easily, and without deploying to cloud. We should run them remotely as well, because remote infrastructure is a bit different from local infrastructure. We can achieve both by setting up a pipeline and staging them as different environments (development, stage, user acceptance testing, pre-production and production), where development and stage testing should be invoked locally, and same testing with better performance is tested remotely on the rest of the environment. 

Static code analysis is the process of analyzing source code to flag programming errors, bugs, stylistic errors, and suspicious constructs. We have to make sure we have to integrate linting tool for serverless function in the pipeline stage. This helps to keep the code clean, less buggy and perfectly indented.