在 R 中跳过 travis 上的特定测试文件
Skip a specific test file on travis in R
我的 testing suite 由多个文件组成。我想在 travis 上跳过其中一个(与拟合贝叶斯模型相关的那个),因为它需要很多时间并且会失败。
我知道我可以使用 testthat::skip_on_travis()
跳过特定测试。但是,这些在 test_that 块中工作。不幸的是,我想跳过的部分(来自 here to here)主要在 test_that 块之外(并且模型拟合发生在 之前 测试)。
我尝试将模型拟合放入 test_that 块中,但其他块找不到模型。我也试过嵌套 test_that 块,但这似乎不起作用...有什么想法吗?
在您的 testthat.R 文件中,您可以使用 filter
参数 test_check
以便有条件地跳过整个文件。此机制可用于跳过 CRAN 或 Travis 上的长测试集合。
另一个似乎有效的选项是检查环境变量:
if (Sys.getenv("USER") != "travis") {
# tests to be executed...
}
另见此处:
https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
我的 testing suite 由多个文件组成。我想在 travis 上跳过其中一个(与拟合贝叶斯模型相关的那个),因为它需要很多时间并且会失败。
我知道我可以使用 testthat::skip_on_travis()
跳过特定测试。但是,这些在 test_that 块中工作。不幸的是,我想跳过的部分(来自 here to here)主要在 test_that 块之外(并且模型拟合发生在 之前 测试)。
我尝试将模型拟合放入 test_that 块中,但其他块找不到模型。我也试过嵌套 test_that 块,但这似乎不起作用...有什么想法吗?
在您的 testthat.R 文件中,您可以使用 filter
参数 test_check
以便有条件地跳过整个文件。此机制可用于跳过 CRAN 或 Travis 上的长测试集合。
另一个似乎有效的选项是检查环境变量:
if (Sys.getenv("USER") != "travis") {
# tests to be executed...
}
另见此处: https://docs.travis-ci.com/user/environment-variables/#default-environment-variables