assertj / assertj/assertj-generator

Feature: Generate IterableAsserts for all generated Asserts

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

説明

We would like to write something like this:

```java
List result;
assertThat(result).singleElement().hasName("Fool")
```

Now, we can generate `FooAssert` with the generator, but the `ListAssert` we get out of `assertThat` in this case does, of course, not known about the generated assertion; we get a regular `ObjectAssert`.

We can work around this by creating something like this here:

```java
public class FooIterableAssert
extends AbstractIterableAssert, Foo, FooIterableAssert> {

protected FooIterableAssert(Iterable foos, Class selfType) {
super(foos, selfType);
}

@Override
protected FooAssert toAssert(Foo value, String description) {
return new FooAssert(value);
}

@Override
protected FooIterableAssert newAbstractIterableAssert(Iterable iterable) {
return new FooIterableAssert(iterable, FooIterableAssert.class);
}

public static FooIterableAssert assertThat(List foos) {
return new FooIterableAssert(foos, FooIterableAssert.class);
}
}
```

This has the feel of "should be a template" and "surely not only we want this", so I'm raising this issue. :)
I'm also not sure whether one would have/want to fiddle with the entrypoint methods in support of this.

PS: I was considering to use Lombok's `@ExtensionMethod` on `ListAssert` to add something like `FooAssert singleFoo()` to it. Unfortunately, it does not seem possible to get the actual _value_ back from an Assert, so I was stuck there.

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

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

調査の方向性

まず FooAssert を作成する assertion generator を追跡し、次に ListAssert と assertThat のエントリーポイントがどのように生成されるかを調べます。要求された FooIterableAssert の形状と現在生成されている出力を比較し、生成された iterable assertions をどのように公開すべきかを判断します。生成された assertions が、手動の wrapper クラスなしで要求された singleElement().hasName("Fool") の使用方法をサポートすれば完了です。

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

評価

技術スタック
java
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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