dimanche 2 août 2015

How do you do test helpers with R's testthat?

Does anyone know how to use helper methods for tests in the testthat package?

For example, my test that an array has a distribution that is not to far away from a Gaussian:

expect_not_too_ungaussian <- function(x){
    x <- (x - mean(x)) / sd(x)
    test <- ks.test(x, pnorm)
    expect_true(test$p.value > .2)
}

Aucun commentaire:

Enregistrer un commentaire