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)。