Testing

This page describes how to run tests on your Forseti contributions. You need to install Forseti before you run the unit tests, either by following the Developer Setup (local installation) or the GCP setup (install on a GCE instance; you will need to connect to that instance to run the unit tests).

Executing tests

You can find unit tests in the top-level tests/ directory. We use unittest from standard Python to run our tests.

Before you run unit tests, build the protos if you haven’t already. Some of the unit tests will fail if they can’t find the required protos.

Run the following commands in the top-level directory of Forseti.

  python build_protos.py --clean

To execute all the unit tests:

  python -m unittest discover -s . -p "*_test*"

To execute the tests just for a particular file pattern:

  python -m unittest discover -s . -p "*some_feature_test*"