I am using testthat
to write tests for my R package. One of my tests makes use of jitter
. I want to make sure the test is reproducible.
Do I put set.seed(1014)
- Before or after
library(testthat)
in./tests/testthat.R
; or - At the top of each test file (before or after
context("Test
) in./tests/testthat/test-function.R
; or - At the top of each unit test (inside of
test_that("Example works"){jitter(1)}))
in./tests/testthat/test-function.R
?
And why?