testthat Questions
2
Is it possible to invoke the debugger in RStudio when running testthat tests? I haven't been able to find a setup that allows this (various combinations of "use devtools package functions if availa...
2
Solved
I'm looking to unit test a function that produces a connection. It outputs a message that contains the connection details during execution.
I want to test the following:
The message appears as e...
2
Solved
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:
...
1
Solved
I am using testthat to write tests for my R package. One of my tests makes use of jitter. I want to make sure the test is reproducible.
Do I put set.seed(1014)
Before or after library(testthat) ...
1
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) {
wri...
2
Solved
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,...
1
Solved
I have built a package with unit tests for most of the functions. The package has a standard structure:
package:
- R/
- file1.R
- file2.R
- ...
- tests/
- testthat/
- tests_for_file1.R
- t...
Skipjack asked 15/10, 2018 at 10:24
2
Solved
For a given installed package, how do I run its testthat tests? I'm not a developer of the installed package, I'm a user. I just want to run its test suite to confirm its tests pass in my environme...
2
I am using the testthat library for unit testing in a R project. I want to test code that relies on database queries, but not test the actual queries themselves. In other words, I'd like to mock th...
1
I have a lot of unit tests using the testthat package that expect english error messages.
If other developer run the tests on a computer configured for a non-english locale the error message are e...
2
Solved
I am calling a function from base in my code and I want to mock this function in my testthat unit test.
How can I do this?
library(testthat)
my.func <- function() {
return(Sys.info()["sysnam...
1
Solved
I am developing an R app and came up with a workaround to integrate testthat in it (it usually requires your project to be a package) by adding a DESCRIPTION file to the project root.
I got this m...
2
Solved
I am looking for best practice help with the brilliant testthat. Where is the best place to put your library(xyzpackage) calls to use all the package functionality?
I first have been setting up a ...
3
Solved
I have a lot of functions that generate plots, typically with ggplot2. Right now, I'm generating the plot and testing the underlying data. But I'd like to know if there's a reasonable way to test t...
Trumpery asked 24/6, 2015 at 23:15
1
Solved
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 t...
2
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...
2
Solved
I have a shiny application which uses like 4 functions. I would like to test these functions but it's not a package. How am i supposed to structure my code ? and execute these tests without devtool...
3
Solved
I want to test that a function generates multiple warnings (4 or more), when the order of the warnings can vary. My best attempt to do this is based on look-ahead RegExp matching. Simplifying to ju...
Blastema asked 1/3, 2016 at 0:34
2
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 re...
2
Solved
1
I would like to run my package unit tests during R CMD check, but skip tests that require an internet connection. By convention, all unit tests that require internet have the word network in their ...
1
Solved
I am developing a Shiny app at the moment and getting to a point with more functions than I expected. I plan to start automated testing with testthat and I would love to document my functions with ...
3
Solved
I have some particularly finicky code that behaves differently on different platforms, but also behaves differently if run under valgrind ... right now I know that it
gives a warning if run on 32...
Purington asked 16/6, 2014 at 21:9
2
Solved
I am writing a R package, and I'm using testthat for unit testing. Many of my unit tests are for testing functions that work on a certain object specific to my package. For these tests I have made ...
Boxthorn asked 11/3, 2016 at 13:39
1
Solved
I have the following function:
fun = function(expr) {
mc = match.call()
env = as.environment(within(
list(),
expr = eval(mc$expr)
))
return(env)
}
that gets called within a tryCatch() so...
© 2022 - 2024 — McMap. All rights reserved.