assertj / assertj/assertj-generator

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

オープン
#91 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
72
フォーク
47
平均マージ
1日 16時間
マージ済み PR(30日)
2

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず pom.xml のジェネレーター設定と issue で参照されているドキュメントを読み、次にスーパークラスの assertion がどのように含まれているかを調べます。SomeErrorException から HttpResponseException を経て Throwable に至る例の階層を追跡し、既存の Assertions.assertThat(Throwable) の制限を確認します。既存の assertion と競合せずに継承プロパティの assertion を生成するための方針が決定され、文書化されていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
testing, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。