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
-1
votes
1 answer

R package development: tests pass in console, but fail via devtools::test()

I am developing an R package that calls functions from the package rstan. As a MWE, my test file is currently set up like this, using code taken verbatim from rstan's example: library(testthat) library(rstan) # stan's own example stancode <- 'data…
half-pass
  • 1,851
  • 4
  • 22
  • 33
-1
votes
2 answers

Can we use funtions from testthat package to test elements of a vector?

I've created a package that has a function, in this case is myfunction(argument1, argument2), that requires only positive inputs that have the same length as arguments. And I want to test whether the input is in a correct format using functions from…
-1
votes
1 answer

Mocking functions inside a for loop in R

I'm using testthat package for unit testing in R. I have a function CalcByResultSubModel which has one more function CalculateX which is called inside the main function. This is the main function, CalcByResultSubModel = function(doll_data,…
Luiy_coder
  • 321
  • 2
  • 11
-1
votes
1 answer

How do define certain tests on certain branches?

I am new to gitlab ci/cd. i like how it works. I would like to run certain tests in certain branches. how can i define the same in yml file? I am using gitlab ci/cd for R package development and using testthat package for unit-testing.
sveer
  • 427
  • 3
  • 16
-1
votes
1 answer

unit tests and checks in package function: do we do checks in both?

I'm a new to R and package development so bear with me. I am writing test cases to keep package is line with standard practices. But I'm confused if I do the checks in testthat, should I not perform if/else checks in the package…
Death Metal
  • 830
  • 3
  • 9
  • 26
-1
votes
1 answer

Run all testthat tests for an R package?

I googled, found this; accordingly, ran test_dir() (it errors), tried test_dir(getwd()) from the package root (it also errors). I also tried test_package(), but it also errors if the argument is left NULL or returns nothing if the package name is…
stevec
  • 41,291
  • 27
  • 223
  • 311
1 2 3
24
25