Skip to content

library before context throws error? #700

@alexpghayes

Description

@alexpghayes

Hoping this is reproducible:

  1. Created a new R package (via new project) using RStudio.
  2. usethis::use_testthat()
  3. usethis::use_test("example")
  4. Modify test-example.R to
library(dplyr)

context("test-example.R")

test_that("multiplication works", {
  expect_equal(2 * 2, 4)
})
  1. devtools::test() gives
> devtools::test()
Loading tmp2
Testing tmp2| OK F W S | Context
Error in x[[method]](...) : attempt to apply non-function

== Results =====================================================================
Duration: 0.2 s

OK:       0
Failed:   2
Warnings: 1
Skipped:  0

but if the context comes before library in test-example.R, everything works. Is this expected? I'm using testthat 2.0.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions