Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Should assertions for properties of the superclass(es) be generated?

Open
#91 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
testing, tooling

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from assertj/assertj-generator

All issues in assertj/assertj-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.