Handling Test Workflows in R testthat

128 views Asked by At

I've two files test_utils.r and test_core.r, they contain tests for various utilities and some core functions separated into different 'context'. I can control the flow of tests within each file by moving around my test_that() statements.

But am looking for a way in which I can create different workflows, say ensuring that at run time, tests from Context A_utils runs first followed by tests from Context B_Core followed by context B_Utils.

Any ideas on how this can be achieved?

1

There are 1 answers

0
micstr On

BrajeshS,

  1. I have an idea. Have you tried the skip() function in version 0.9 or better? See documentation on page 7:

    Description

    This function allows you to skip a test if it’s not currently available. This will produce an informative message, but will not cause the test suite to fail.

    It was introduced to skip tests if an internet connection or API not available. You could then dependent on your workflow, jump over tests.

  2. To see example code using skip_on_cran, look at wibeasley's answer where he provides test code in Rappster's reply - https://stackoverflow.com/a/26068397/4606130

I am still getting to grips with testthat. Hope this helps you.