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 embed something within the roxygen2 documentation…
I am using the testthat package to write tests for my R package. I have followed the instructions at http://r-pkgs.had.co.nz/tests.html (I believe). I used
devtools::use_testthat()
to set up the testing skeleton. I have created a test file in…
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 following instructions here.
Is the testthat package…
Can anyone run testthat tests for a minimal R package using GitLab.com continuous integration tools?
My attempt:
https://gitlab.com/djchapman/CI_example
This is the .gitlab-CI.yml text I am using,
image: rocker/rstudio
test:
script:
- R -e…
I have R code (not a package) which I would like to cover with acceptance tests using testthat with output being used in Jenkins.
I can start with two files which demonstrate the code structure:
# -- test.R
source("test-mulitplication.R")
# --…
I'm having trouble using testthat's tolerance parameter when I check whether two data_frames are equal. Here's a simple example with two data frames:
library(dplyr)
library(testthat)
d1 = data_frame(a = c(1, 1),
b = c(2, 2))
d2 =…
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 that indicate a softer dependency, i.e. Suggests and…
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 code in a file called test_message.R
f <-…
(This question is also asked at Github here)
After an upgrade of R to 4.0.2 tests fail because it seems, the algorithm of sort in testthat changed. The following shows, that base::sort() and browser() are fine in R 4.0.2 (See this question, why this…
I have a routine that returns a data frame. I want to check if its values are reasonable. Using testthat I have expect_equal, but I am not sure if it applies to data.frames. I tried to do this but it doesn't…
I am trying to write a test for a package function in R.
Let's say we have a function that simply writes a string x to disk using writeLines():
exporting_function <- function(x, file) {
writeLines(x, con = file)
invisible(NULL)
}
One way of…
I am developing an R package and one of the function implements interaction with users through standard input via readline. I now wonder how to test the behavior of this function, preferably with testthat library.
It seems test_that function…
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 error because system.file("tests", package = package) is…
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 package.
Here's my environment:
sessionInfo()
R…
What is the proper way to skip all tests in the test directory of an R package when using testthat/devtools infrastructure? For example, if there is no connection to a database and all the tests rely on that connection, do I need to write a skip in…