Q:

Control order of script executions in test_package

Is it possible to control the order in which test_package executes testing scripts? I would like to start by executing some code that creates some objects shared by all individual tests. Therefore, this script needs to be executed first, before the actual test-blabla.R scripts.
I could try something like test-AAA.R or test-000.R, but I am not sure if the dir function used by testthat to list the scripts in a package, returns the same (alphabetical?) order of files on all platforms.

A:

?test_dir says

Test files start with ‘test’ and are executed in alphabetical
       order (but they shouldn't have dependencies). Helper files start
       with ‘helper’ and loaded before any tests are run.

So, use helper files.  i.e. create a file with a name that begins with "helper" and put in it the code that you need to run before running all the tests.

