REQUIRED_FILES 文件¶
运行测试所需的文件列表。除非指定绝对路径,否则文件名是相对于测试 WORKING_DIRECTORY 的。
如果设置为文件列表,除非所有文件都存在,否则不会运行测试。
例子¶
假设 test.txt 是由测试 baseTest 创建的,而 none.txt 不存在:
add_test(NAME baseTest ...) # Assumed to create test.txt
add_test(NAME fileTest ...)
# The following ensures that if baseTest is successful, test.txt will
# have been created before fileTest is run
set_tests_properties(fileTest PROPERTIES
DEPENDS baseTest
REQUIRED_FILES test.txt
)
add_test(NAME notRunTest ...)
# The following makes notRunTest depend on two files. Nothing creates
# the none.txt file, so notRunTest will fail with status "Not Run".
set_tests_properties(notRunTest PROPERTIES
REQUIRED_FILES "test.txt;none.txt"
)
上面的示例演示了 REQUIRED_FILES 是如何工作的,但它并不是实现带有故障检测的测试排序的最可靠方法。为此,测试夹具是更好的选择(请参阅:prop_test:FIXTURES_REQUIRED)。