I am finding some weird results using testthat
. When running test_file
, individual test_that
calls are discovered but there is no output to the console other than the name of the context and the returned data.frame
does not have the expected results. I suspect I am doing something really dumb but have tried lots of alternatives and get the same outcome.
Here is my tests.r
file:
context("The universe")
test_that('the answer is right',function(){
# Should be OK
expect_equal(42,42)
})
test_that('the question is wrong',function(){
what_is_the_meaning <- function(){
42
}
# Should fail
expect_equal(what_is_the_meaning,NULL)
})
test_that('an error occurs',function(){
# Should cause an error because undefined
authur^4
})
I run test_file
on it:
> require(testthat)
Loading required package: testthat
> test_file('tests.r')
The universe :
> results <- test_file('tests.r')
The universe :
> results
file context test nb failed error user system real
1 tests.r The universe the answer is right 0 0 FALSE 0.004 0 0.002
2 tests.r The universe the question is wrong 0 0 FALSE 0.000 0 0.000
3 tests.r The universe an error occurs 0 0 FALSE 0.004 0 0.001
As you can see, no console output and in the results data.frame
instead of having one failed test and one with an error it looks like everything has passed.
This is what I am running:
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_NZ.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_NZ.UTF-8 LC_COLLATE=en_NZ.UTF-8
[5] LC_MONETARY=en_NZ.UTF-8 LC_MESSAGES=en_NZ.UTF-8
[7] LC_PAPER=en_NZ.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] testthat_0.9.1
Aucun commentaire:
Enregistrer un commentaire