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

not_shows_message and not_prints_text #64

Closed
wush978 opened this issue Feb 8, 2013 · 6 comments
Closed

not_shows_message and not_prints_text #64

wush978 opened this issue Feb 8, 2013 · 6 comments

Comments

@wush978
Copy link

wush978 commented Feb 8, 2013

I think it might be useful for not_shows_message or not_prints_text which is similar to shows_message and prints_text except that the test is fail instead of pass.

For example, I need to test if executing an external program does not produces warning message.

@wush978
Copy link
Author

wush978 commented Feb 15, 2013

Hi,

I have created R functions not_shows_message and not_matches in https://github.com/wush978/test_that/commit/560ecb2123a9264a6f7c3967fb0535f0a065f0f8

Since I'm still not familiar with test_that, the proposed features might be redundant or inappropriate. Please give me some instructions or feedback about this issue.

Thanks.

@hadley
Copy link
Member

hadley commented Feb 15, 2013

I agree that these tests are needed and currently missing (see also #62), but I'd really like some global way of doing this, rather than having to create a negated version of every single expectation.

@richfitz
Copy link

Would it be possible to have a not() function (as in https://gist.github.com/richfitz/5056365), and have each expectation function prepare a string for success and for failure. The not() function would just toggle the value of passed and select the alternative string.

There aren't so many expectations that this seems like a huge change, doesn't proliferate expectations, and would be backward compatible with user-defined expectations if it is possible to come up with a string that indicates that it was expected that test would fail.

@hadley
Copy link
Member

hadley commented Feb 28, 2013

@richfitz Yeah, I was just thinking about that too. I think it's a solid approach.

@hadley
Copy link
Member

hadley commented Jun 6, 2013

Please see 1b1987b and b475797. If this looks good for the expect_that form, I'll add negated helpers.

@hadley hadley closed this as completed Jun 7, 2013
@muschellij2
Copy link

Is this still the case since not() is becoming deprecated?

Or should it be something like testthat::expect_failure(expect_warning(expr))

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

4 participants