assertj / assertj/assertj-generator
Should assertions for properties of the superclass(es) be generated?
- Dominant language
- Java
- Stars
- 72
- Forks
- 47
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 2
Description
Consider this class:
```
import org.apache.http.client.HttpResponseException;
public class SomeErrorException extends HttpResponseException {
private SomeError error;
public SomeErrorException(int statusCode, String reason, SomeError error) {
super(statusCode, reason);
this.error = error;
}
public SomeError getError() {
return error;
}
}
```
It would be nice to be able to test `SomeErrorException` objects like this:
```
assertThat(exception).hasStatusCode(500)
.hasMessage("Internal Server Error")
.hasError(error)
```
However, `hasStatusCode` and `hasMessage` are not generated because they are defined in superclasses. If I include `HttpResponseException` in the generator configuration (in `pom.xml`), the `hasStatusCode` appear, but of course `hasMessage` is only present if I also include the whole hierarchy (four classes!) up to `Throwable`. Also, `org.assertj.core.api.Assertions.assertThat(Throwable)` already exists, so I cannot make my assertions a subclass (but problem with this idea are already discussed in the documentation).
Does it make sense to make it easier to include assertions for properties of superclasses?
Contributor guide
Assessment
This issue has not been assessed yet.