testthat Questions
2
Solved
I would like to test an installed package, but this returns an error.
library(testthat)
test_package("testthat")
# Error: No tests found for testthat
test_package (source here) returns this erro...
1
Solved
I'm just now getting into unit testing with R and finding it tough sledding so far. What I'd like to do is go into the R console, type test() and have testthat run tests for all the files in my R p...
2
Solved
I'm working on the PKNCA package for R. While developing the testing code, some of the tests would also be good examples. I want to keep them as both (test and example). Is there a way that I can e...
2
Solved
Suppose I have test like this:
require(testthat)
context("toy test")
test_that("toy", {
df = my.read.file("test.txt", header=TRUE)
expect_true(myfunc(df) == 3.14)
})
and this test relies on a ...
3
Solved
I am writing a script that ultimately returns a data frame. My question is around if there are any good practices on how to use a unit test package to make sure that the data frame that is returned...
Heterozygous asked 26/3, 2015 at 15:49
2
Solved
What is the correct usage of expect_error() in testthat package? I've tried to adapt example from help, but this fails when I use brackets in error message.
library(testthat)
# Works
tmp1 <- fu...
1
Solved
Can anybody help me and explain why expect_that doesn't work if [] is added to the stop message, i.e. f1 works but f2 doesn't.
library(testthat)
f1 <- function(x){
if( x >= 1 ){
stop("erro...
1
Solved
Packages in R can have different types of dependencies on other packages. Some of these types indicate hard requirements, i.e. Depends, Imports and LinkingTo.
However, there is a second category t...
2
Solved
I have a bunch of tests that I don't want them running during CRAN checks or Travis CI builds. They are either long-running, or they could cause transaction/concurrency conflicts writing to a netwo...
1
Solved
I would like to know if it is possible in R using testthat test framework to set the tolerance for equality.
Currently, if example.R is:
library(testthat)
three_times<-function(x) 3*x
context...
Bony asked 23/8, 2014 at 15:25
2
Solved
I'm trying to do some unit testing using the testthat package but I can't seem to get it to work properly together with the rms package. The following example:
library(rms)
set.seed(10)
ds <- d...
2
Solved
I am using the excellent testthat package in R. My issue is that I cannot see any output from the message() function in the code being tested when using test_file. for example, say I have following...
2
Solved
I'd like to test that one of my functions gives a particular message (or warning, or error).
good <- function() message("Hello")
bad <- function() message("Hello!!!!!")
I'd like the first ...
1
Solved
I have a function in a package I'm building that assigns a hex-code to the global environment for use by analysts...
optiplum<-function(){
assign(
x="optiplum",
value=rgb(red=129,green=61,bl...
1
I am creating an R package, and found it useful to break parts of the logic in one file into internal helper functions, which I define in the same file. I have sort of a special case where my funct...
1
Solved
I am using testthat to test a package with a file tree similar to the following:
.
├── data
│ └── testhaplom.out
├── inst
│ └── test
│ ├── test1.r
│ ├── tmp_S7byVksGRI6Q
│ │ └─...
1
Solved
There are apparently two ways to integrate testthat with R CMD check. I can't get either to work.
Approach #1: (perhaps deprecated)
According to the devtools wiki:
When developing a package, ...
1
Solved
I am contributing to an R package that makes extensive use of C code for computation.
We have started writing tests for R functions using the testthat package, placing the tests in inst/tests foll...
Fuscous asked 27/5, 2013 at 19:42
2
Solved
How can I automatically generate test cases in RUnit?
For example, let's say I have a simple sum() function:
sum <- function(x, y) {
return (x + y)
}
I would like to test this function on ...
2
Solved
I am developing an R package that wraps the rmongodb package and creates a developer-friendly interface for working with MongoDB. The package uses proto internally.
I'd like to export a single fa...
© 2022 - 2024 — McMap. All rights reserved.