Is it possible to determine the order of testing in the test?

I use testthat to check the code in my package. Some of my tests are for basic functions like constructors and getters. Others are for complex functions that are based on core functions. If the basic tests fail, it is expected that complex tests will fail, so there will be no further testing.

Is it possible:

  • Make sure that basic tests are always performed first.
  • Make a test crash stop the testing process
+8
unit-testing r testthat
source share
1 answer

To answer your question, I do not think it can be defined otherwise than by the corresponding alphanumeric name of your test-*.R files.

From the source testthat , this is the function that test_package calls through 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 if you just solve the difficult task in the first place?

+5
source share

All Articles