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...
Metathesis asked 21/7, 2015 at 20:16

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...
Plagioclase asked 31/3, 2016 at 11:58

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: ...
Trichloroethylene asked 9/10, 2017 at 21:12

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) ...
Ravenravening asked 17/5, 2019 at 18:33

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...
Redraft asked 31/10, 2018 at 10:8

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,...
Lucrece asked 15/8, 2018 at 21:49

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...
Tbilisi asked 4/9, 2018 at 23:44

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...
Taffeta asked 26/8, 2016 at 18:32

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...
Industrialism asked 26/12, 2017 at 11:27

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...
Diley asked 20/5, 2018 at 19:17

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...
Aphid asked 29/4, 2018 at 4:56

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 ...
Felipe asked 10/4, 2015 at 8:41

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...
Toogood asked 29/12, 2016 at 1:52

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...
Colotomy asked 20/11, 2015 at 6:37

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...
Malawi asked 9/8, 2017 at 10:9

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...
Beatify asked 9/1, 2016 at 8:7

2

Solved

I am wondering how to test functions that produce graphics. I have a simple plotting function img: img <- function() { plot(1:10) } In my package I like to create a unit test for this functi...
Chic asked 14/5, 2015 at 20:31

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 ...
Disillusionize asked 26/3, 2014 at 23:29

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 ...
Emissary asked 9/6, 2016 at 7:29

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...
Loup asked 16/6, 2016 at 23:24

© 2022 - 2024 — McMap. All rights reserved.