Questions tagged [testthat]

testthat is a testing tool for R.

testthat is an package for , which is inspired by the family of testing packages and various testing libraries.

Repositories

Other resources

Related tags

366 questions
0
votes
1 answer

R Source file location problem while using testthat

I'm trying to setup the testthat unit test framework and having some trouble to get the source file location right. My package folder structure is like below: .\R\abc.R .\R\def.R .\tests\testthat\test_01.R In my test case file test_01.R, I need to…
Allen Qin
  • 19,507
  • 8
  • 51
  • 67
0
votes
0 answers

testthat expect_identical FALSE until wrapped in as.data.table

I have read up on the differences between expect_equal and expect_identical. That being said, I have a function which produces a data table that looks like: Thing1 Thing2 Thing3 Thing1 34.6 23.4 54.2 Thing2 34.7 33.2 32.1 Thing3 …
C-x C-c
  • 1,261
  • 8
  • 20
0
votes
2 answers

How to test an R function which uses Sys.time()?

I have the following R function within a software package, which outputs Sys.time() to the output for users to know how the algorithm is proceeding: func = function(num1, num2){ result = num1 + num2 return(paste0(' ',…
EB2127
  • 1,788
  • 3
  • 22
  • 43
0
votes
1 answer

Gitlab stop CI if Dockerized R CMD check return errors

How can I make my CI pipeline fail if the test stage return errors ? Here is my test stage : Test: stage: Test script: - docker build -t r-docker-ci-test -f test.Dockerfile . - docker run r-docker-ci-test Here is my test.Dockerfile :…
CARREAU Clément
  • 657
  • 5
  • 16
0
votes
0 answers

Removing email from package testing using testthat

I'm developing a package that uses your personal email to log in to a website to download some data. When I test the functions using testthat I use my email, but I wouldn't want my email to be uploaded into Github because other users might use it to…
cimentadaj
  • 1,414
  • 10
  • 23
0
votes
1 answer

gWidget : is there a way to emulate user actions in testthat?

In my package, I'm using testthat and gWidgetRGtk2, I would like to know if there is a way to emulate user actions from the code line, for instance in the following I'm testing an action where the user pushes a button. So far I've been unable to…
Cedric
  • 2,412
  • 17
  • 31
0
votes
1 answer

How to test standalone R scripts which are part of a package using testthat

I am building a R package, RE and I would like to package a standalone script with it to be placed in RE/exec/wrapper.R. I have written a test function for testthat which works just fine when run from the command line using devtools::test("RE"), but…
0
votes
3 answers

How to tell if any tests failed from result of testthat::test_dir

I have a small testing program that uses testthat library(testthat) source("src/MyFile.r") results <- test_dir("tests", reporter="summary") So, I am running this via Rscript. The problem is that the exit code is always 0 even when there were test…
jamesatha
  • 7,280
  • 14
  • 37
  • 54
0
votes
2 answers

How to display testthat results in the travis log?

I am testing an R package called eutradeflows on travis. The package contains test programmed with testthat and I would like to see the output of devtools::test() in travis. There was a line in the main travis log saying : Status: 4 NOTEs See …
Paul Rougieux
  • 10,289
  • 4
  • 68
  • 110
0
votes
2 answers

How to write unit tests for a sequence of data transformations?

I am trying to learn TDD while writing a script that transform its input data in a long series of functions. The problem is similar whether I write it in python or R. I guess it's more related to TDD understanding. # Look of main in python def…
xav
  • 4,101
  • 5
  • 26
  • 32
0
votes
1 answer

Handling inconsistent test results when scraping a fluctuating website

Would appreciate advice from the community on how best to handle an aggravating situation. I have a R package that scrapes the National Hurricane Center archives and returns tidy storm data. The website often does not respond. An example of this…
timtrice
  • 307
  • 3
  • 12
0
votes
1 answer

parse does not return attributes in Rstudio test environment and Travis

The package parseMe has a single function parseMe <- function(text) { parsed = parse(text = text) str(parsed) #for diagnosis getParseData(parse(text = parsed)) } this function is tested using testthat test_that('parseMe',{ …
OganM
  • 2,543
  • 16
  • 33
0
votes
1 answer

git2r::summary() produces different results when called from console and by RStudio

I am trying to write an R package that analyzes Apache Pig GitHub repository with the help of git2r package. I also use testthat package for unit testing. I have a function, let's call it compute(), which contains code along the lines of: repo <-…
Dragomok
  • 604
  • 3
  • 11
  • 29
0
votes
1 answer

How to add a reporter to testthat?

I'm trying to add a JUnit reporter to testthat. While I can do it inside the package (https://github.com/hadley/testthat/pull/481) I cannot make it pass the same set of tests when in a separate package (https://github.com/lbartnik/testthatJUnit). My…
Lukasz
  • 148
  • 11
0
votes
1 answer

Package fail on CRAN due to test using testthat

I submitted my package to CRAN and it did not pass the CRAN R CMD check. This is the error they get: * checking tests ... ERROR Running the tests in ‘tests/testthat.R’ failed. Last 13 lines of output: Type 'contributors()' for more information…
ayalaall
  • 145
  • 2
  • 16