Should assertions for properties of the superclass(es) be generated?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reading the generator configuration in pom.xml and the documentation referenced in the issue, then inspect how superclass assertions are included. Trace the example hierarchy from SomeErrorException through HttpResponseException to Throwable and review the existing Assertions.assertThat(Throwable) limitation. Done means a decided, documented approach for generating inherited-property assertions without conflicting with existing assertions.
Written by the indexing model from the issue text.
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?
- Dominant language
- Java
- Stars
- 72
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from assertj/assertj-generator
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
assertj/assertj-generator#278 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
assertj/assertj-generator#220 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
assertj/assertj-generator#219 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
assertj/assertj-generator#204 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
assertj/assertj-generator#197 · 7 comments ·
All issues in assertj/assertj-generator
Similar issues
-
certification
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's Openbug ecr
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Needs: Triage Type: Feature request
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
AntennaPod/AntennaPod#8794 ·
-
agentic-workflows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/copilot-sdk#2760 ·