bazelbazel-python

Can I create a BUILD file that can reference and run several tests?


I have a python project with unit tests (unittest module) organized like this:

./WORKSPACE
./test/topic_a/BUILD
./test/topic_a/class_name_a_test.py
./test/topic_b/BUILD
./test/topic_b/class_name_b_test.py

The majority of the time this is fine and I run tests with:

bazel test //test/topic_a

I would like to have a BUILD at the project root to run all the tests in the project. I've been looking for a way to create a test where I can list all the labels from subdirectory BUILD files I want included, but have so far come up empty. Is this possible?


Solution

  • I think test_suite is what you're looking for. Something like this:

    test_suite(
        name = "the_tests",
        tests = [
            "//test/topic_a",
            "//test/topic_b",
        ],
    )