Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

covr does not correctly interact with testit multiple line check #10

Open
tomasruizt opened this issue Jun 30, 2020 · 1 comment
Open

Comments

@tomasruizt
Copy link

Hi, not sure if this is really an error, but it seems to me like testit would intend to support this common setup:

  • testthat for unit tests
  • testit for runtime assertions in functions
  • covr for code coverage

The setup works well unless I use testit::assert on several lines, like in the testit README file

Example:
file R/myfuncs.R

failFunc <- function() {
    assert("Foo", {
        (FALSE == TRUE)
        (TRUE == TRUE)
    })
}

test file tests/testthat/test.myfuncs.R

test_that("failFunc fails", {
     expect_error(failFunc())
})

when running devtools:test() the test passes as expected. However, with the command covr::package_coverage() the test does not pass, apparently because the first assertion (FALSE == TRUE) is not evaluated. Changing the function fixes this, but is not in the spirit of testit:

failFunc <- function() {
    assert("Foo", {
        (FALSE == TRUE) &&
        (TRUE == TRUE)
    })
}

Not sure if this is related to the way covr works or is part of the testit internals.

@yihui
Copy link
Owner

yihui commented Jun 30, 2020

This is far beyond my expertise, so I don't know. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants