Testing

Basics

  • Run all tests: To execute the entire test suite in your local development environment, run

    make test               # to run unit-tests
    make test-integration   # to run integration/"acceptance" tests
    

    These make targets are a convenient way to invoke the actual build and test tool, bazel. See the Makefile for the definition of the targets. The referenced bazel --config are defined in .bazelrc.

  • Unit tests for individual go packages: To run tests for individual go packages, like for example pkg/snet, invoke bazel test directly and specify the test as a bazel target:

    bazel test --config=unit //pkg/snet:go_default_test # unit test for exactly pkg/snet
    bazel test --config=unit //pkg/snet/...             # unit tests for all packages under pkg/snet
    
  • Run individual go test cases: Use the --test_filter=<regex> option to filter on the level of individual test cases.

    bazel test --config=unit //pkg/snet:go_default_test --test_filter=TestPacketSerializeDecodeLoop
    
  • Useful bazel test flags: Finding a flag in the bazel command line reference can be tricky, so here are some pointers:

Advanced