test_suite()
A test_suite()
is used to create a grouping of tests that should all be run by just testing this rule.
This rule can then be given to buck test
, and all tests that it depends on will be invoked. Note that the test_suite() target is not tested itself, it just tells buck to run other tests. It will not show up in calls to the external runner nor in the normal test output.
Arguments
name
(required) #The short name for this build target.
tests
(defaults to[]
) #A list of build targets that should be tested.
visibility
(defaults to[]
) #List of build target patterns that identify the build rules that can include this rule as a dependency, for example, by listing it in their
deps
orexported_deps
attributes. For more information, see visibility.licenses
(defaults to[]
) #Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use
buck query
.labels
(defaults to[]
) #Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query attrfilter()
.
Examples
This test_suite() sets up two different sets of tests to run, 'all' tests and 'slow' tests. Note thatall_tests
can depend on slow_tests
, and all three tests are run.# instrumentation_tests/BUCK: sh_test( name = "instrumentation_tests", test = "instrumentation_tests.sh", visibility = ["PUBLIC"], ) # integration_tests/BUCK: sh_test( name = "integration_tests", test = "integration_tests.sh", visibility = ["PUBLIC"], ) # unit_tests/BUCK: sh_test( name = "unit_tests", test = "unit_tests.sh", visibility = ["PUBLIC"], ) # BUCK: test_suite( name = "slow_tests", tests = [ "//instrumentation_tests:instrumentation_tests", "//integration_tests:integration_tests", ], ) test_suite( name = "all_tests", tests = [ ":slow_tests", "//unit_tests:unit_tests", ], )Yields output like this when run:
$ buck test //:slow_tests ... RESULTS FOR //instrumentation_tests:instrumentation_tests //integration_tests:integration_tests PASS <100ms 1 Passed 0 Skipped 0 Failed //instrumentation_tests:instrumentation_tests PASS <100ms 1 Passed 0 Skipped 0 Failed //integration_tests:integration_tests TESTS PASSED ... $ buck test //:all_tests RESULTS FOR //instrumentation_tests:instrumentation_tests //integration_tests:integration_tests //unit_tests:unit_tests PASS <100ms 1 Passed 0 Skipped 0 Failed //instrumentation_tests:instrumentation_tests PASS <100ms 1 Passed 0 Skipped 0 Failed //integration_tests:integration_tests PASS <100ms 1 Passed 0 Skipped 0 Failed //unit_tests:unit_tests TESTS PASSED