tests/testthat/test-autogen.R

context('Testing Autogeneration')

test_that('stub.tests', {

  test_project <- tempfile('test_project')
  suppressMessages(create.project(test_project))
  on.exit(unlink(test_project, recursive = TRUE), add = TRUE)

  oldwd <- setwd(test_project)
  on.exit(setwd(oldwd), add = TRUE)

  suppressMessages(stub.tests())

  expect_true(file.exists(file.path('tests', 'autogenerated.R')))
  test.code <- scan(file.path('tests', 'autogenerated.R'), what = 'character', sep = '\n', quiet = TRUE)
  expect_that(test.code, equals("expect_that(helper.function(), equals(NULL))"))

})

Try the ProjectTemplate package in your browser

Any scripts or data that you put into this service are public.

ProjectTemplate documentation built on July 31, 2021, 5:07 p.m.