I am running some unit tests using the testthat package. I have a function that is tested repeatedly under various conditions. My problem is that the function has three kinds of "outputs":
Prints to the console. This should be discarded.
Elicits a…
I am building unit tests for an R-package that I am developing. I am using testthat, and for some of the functions, I am using testthat::expect_known_value()
I am saving the reference files created by expect_known_value() in a folder inside the…
I'm trying to submit a PR to library(broom) which relies on testing a bunch of different libraries. Is there a quick way to install all the packages used in the testing suite?
Suppose you declared following function:
compound <- function(x,i,t) {
x*(1+i)^t
}
What are the fundamentals of following results:
compare(compound(100, 0.1, 2),121) => 'Equal'
and
identical(compound(100, 0.1, 2),121) => FALSE
In the package…
I am quite new to unit testing, and I would like to implement some simple unit tests for the functions of an R package. The problem is that most functions of this R package are currently not exported, so that most of unit tests will concern R…
I would like to use the testthat package to test a function that is enclosed by another function.
How can I test such a function?
If this is not possible, how can I refactor the code so that testing objective_function is possible?
Illustrative…
Below I present an issue I have with Rstudio's test feature. It is a simplified version of what I do in a package. I surely have done something wrong but I cannot figure out what. I discovered it when I started to make changes on a package on CRAN.…
The problem
I'm using the read_delim function to read in a lot of csv files (non-comma delimited). This produces warnings because some of the columns have the same name. I don't want to edit the original files, and I cannot change the column names…
Where to place this function:
skip_on_any <- function() {
skip_on_cran()
skip_on_travis()
skip_on_appveyor()
skip_on_bioc()
}
So that I can use it within any of my test files.
I'm writing a package which compares requested packages to available packages. That is, I can ask for 'mgsub == 1.5.0' and I want to see if I already have that version of a package installed before taking any action. I'm determining the already…
When we use testthat in R, the package looks in tests/testthat directory and execute all the files that starts with 'test'... but if i have this type of…
I want the function to produce an error in a try block if a condition is faced, and output one of the inputs without any change in the case of this error. Please note that I do not wish to create a list output or anything as I need to have…
I have an legacy project that doesn't uses namespaces. When I add testthat package it seams that it shadows some functions from magrittr package, especially magrittr::equals. I use roxygen to import packages, and import in comments only magrittr…
I am trying to access a data file on a inst/extdata file from a Rcpp Catch2 test. The file tree looks like this:
├── inst
│ └── extdata
│ └── data-sample
├── R
│ ├── catch-routine-registration.R
│ └── RcppExports.R
├── src
├──…
I'm trying to test my package to ensure that a message printed to the screen ends in a carriage return. When I try to match the carriage return at the end, it never succeeds. is there a way to match the carriage return?
library(testthat)
foo <-…