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...
Oops asked 12/4, 2016 at 13:38

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...
Deste asked 25/3, 2016 at 18:26

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...
Bein asked 4/12, 2015 at 4:24

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 ...
Jordans asked 26/5, 2015 at 20:13

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...
Cornall asked 11/7, 2013 at 9:57

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...
Verso asked 1/2, 2015 at 19:38

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...
Mucoviscidosis asked 12/1, 2015 at 17:40

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...
Soule asked 31/8, 2014 at 19:26

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...
Mistakable asked 30/12, 2012 at 13:10

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...
Greenleaf asked 15/7, 2014 at 20:47

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 ...
Koenraad asked 29/6, 2014 at 9:23

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...
Mattress asked 10/2, 2014 at 10:36

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...
Trabeated asked 9/10, 2013 at 18:11

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 │   │   └─...
Birdie asked 26/9, 2013 at 16:45

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, ...
Abdel asked 11/7, 2013 at 14:15

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 ...
Loathing asked 18/9, 2012 at 15:3

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...
Feverwort asked 22/12, 2012 at 8:5

© 2022 - 2024 — McMap. All rights reserved.