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

expectations not wrapped in 'test_that()' call don't get reported #427

Closed
kevinushey opened this issue Mar 25, 2016 · 3 comments
Closed
Labels
bug an unexpected problem or unintended behavior reporter 📝
Milestone

Comments

@kevinushey
Copy link
Collaborator

Not sure if this is intended or not, but I noticed that with the current development version of testthat tests are not reported (e.g. with the little .) when not wrapped in test_that().

Is this a regression or intended behavior?


Repro:

cd $TMPDIR
rm -rf hellotestthat
R -e 'devtools::create("hellotestthat")'
cd hellotestthat
R -e 'devtools::use_testthat()'
echo -e 'context("Hello")\nexpect_true(TRUE)\n' > tests/testthat/test-hello.R
R -e 'devtools::test()'

With old testthat:

> devtools::test()
Loading hellotestthat
Loading required package: testthat
Testing hello
Hello : .

DONE

New testthat:

> devtools::test()
Loading hellotestthat
Loading required package: testthat
Testing hello
Hello:

DONE ===========================================================================
@hadley
Copy link
Member

hadley commented Mar 25, 2016

Definitely a regression :/

@kevinushey
Copy link
Collaborator Author

It looks like the problem is that all of the reporter handling only gets registered in the test_code function (which is called by test_that):

https://github.com/hadley/testthat/blob/94fc45a2e9b92168d0f74328bcfaad66108daaaf/R/test-that.R#L76-L89

Does it make sense to move this registration code into e.g. test_file?

@krlmlr
Copy link
Member

krlmlr commented Mar 29, 2016

The current code makes sure that errors and skips do not propagate beyond the test_that() block. I guess we need a second, thinner withCallingHandlers() in test_file() (and probably elsewhere) if we want the dots in "bare" expectations.

@krlmlr krlmlr modified the milestone: 1.0.3 Jul 4, 2016
@hadley hadley added bug an unexpected problem or unintended behavior reporter 📝 labels Dec 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior reporter 📝
Projects
None yet
Development

No branches or pull requests

3 participants