Skip to content

Assert non-existence of a particular error #50

Description

@kriegfrj

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions