Is it possible to determine test order in testthat?

梦想与她 提交于 2019-11-29 17:41:13

问题


I am using testthat to check the code in my package. Some of my tests are for basic functionality, such as constructors and getters. Others are for complex functionality that builds on top of the basic functionality. If the basic tests fail, then it is expected that the complex tests will fail, so there is no point testing further.

Is it possible to:

  1. Ensure that the basic tests are always done first
  2. Make a test-failure halt the testing process

回答1:


To answer your question, I don't think it can be determined other than by having appropriate alphanumeric naming of your test-*.R files.

From testthat source, this is the function which test_package calls, via test_dir, to get the tests:

find_test_scripts <- function(path, filter = NULL, invert = FALSE, ...) {
  files <- dir(path, "^test.*\\.[rR]$", full.names = TRUE)

What is wrong with just letting the complex task fail first, anyway?



来源:https://stackoverflow.com/questions/32931886/is-it-possible-to-determine-test-order-in-testthat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!