dia05
dia05

Reputation: 193

How to run a test file taking into account the functions

I create a golem project. I created a test file with the command golem::add_fct("calc", with_test = T). When i execute the command test_file, it doesn't find my function.

test/testthat/test-calc.R

test_that("multiplication works", {
  res <- calc(2, 2)
  expect_equal(res, 4)
})

R/fct_functions.R

calc <- function(a,b){ return(a*b) }

In console

> test_file("tests/testthat/test-calc.R")
[ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]

── Error (test-calc.R:11:3): multiplication works ─────
Error in `calc()`: could not find function "calc"

Upvotes: 0

Views: 42

Answers (0)

Related Questions