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
的工作方式,但这并不是实现带有故障检测的测试排序的最稳健方法。针对这种情况,测试装置是一个更好的替代方法(请参见 FIXTURES_REQUIRED
)。