Running the unit test

Now that we have all the test suites, rather than run them in your IDE, such as PyCharm, you can run the tests from the root folder using the following bash command:

$ python3 -m unittest discover test 

unittest automatically detects that all of the test files must be modules or packages importable from the top-level directory of the project. Here, we just want to run the tests from the test folder that begin with the test_ prefix. 

I have created a shell script under serverless-microservice-data-api/bash/apigateway-lambda-dynamodb/unit-test-lambda.sh:

#!/bin/sh (cd ../..; python3 -m unittest discover test) 

Get Building Serverless Microservices in Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.