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

Assert non-existence of a particular error #50

Open
kriegfrj opened this issue Jul 29, 2014 · 1 comment
Open

Assert non-existence of a particular error #50

kriegfrj opened this issue Jul 29, 2014 · 1 comment
Labels
P3 type=enhancement Make an existing feature better

Comments

@kriegfrj
Copy link

In the annotation processor that I am working on, I have run across a case where it is meaningless to report error2 if error1 is detected. Thus as a feature I would like my processor to not output error2 if it has output error1, and I would like to test that my processor is doing the right thing.

Unfortunately the current API doesn't provide for this case easily, as it only allows you to assert the existence of a particular error, or the non-existence of all errors.

In my tests I got around this problem by testing for the existence of error2 using withErrorContaining(), wrapping it in a try/catch, and silently continuing if no AssertionError is caught or else throwing my own AssertionError if it wasn't. However, this is a little ugly and the diagnostics are not as informative as they might be with a "native" implementation in the compile-testing API itself.

I would like to be able to do something like:

failsToCompile().withErrorContaining(error1).in(file).onLine(line1).and()
                     .withNoErrorContaining(error2).in(file).onLine(line2);
@gk5885
Copy link
Contributor

gk5885 commented Oct 1, 2014

That seems totally reasonable to me.

@raghsriniv raghsriniv added the P3 label Jun 26, 2019
@cgdecker cgdecker added the type=enhancement Make an existing feature better label Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

4 participants