google / google/compile-testing

in() should be optional for single-source subject assertion chains

Open
#51 0 comments 0 reactions 0 assignees View on GitHub
P3 type=enhancement
Dominant language
Java
Stars
722
Forks
129
Avg merge
11m
Merged PRs (30d)
4

Description

Admittedly I'm pretty new to compile-testing, but I have found in my short time that the bulk of my tests consist of single source files that are designed either to exercise particular error conditions in my annotation processor. Of course given that only one file is being compiled the error will always be in that file. Currently, however, in the `javaSource()` subject, you still have to specify `in()` when checking the errors. Instead of:

``` java
ASSERT.about(javaSource())
.that(file)
.failsToCompile()
.withErrorContaining("error msg")
.in(file).onLine(1).atColumn(6);
```

...I'd like to be able to omit in():

``` java
ASSERT.about(javaSource())
.that(file)
.failsToCompile()
.withErrorContaining("error msg")
.onLine(1).atColumn(6);
```

I think it would be good to still have in() as an option (because the error might conceivably happen in another file other than your single source - eg, a generated file). However, I have already come across this pattern so many times that I think it would be a useful enhancement.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.