Add custom exception assertions
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
リンク先の AssertJ ガイドにある既存の「2.6.2 Custom Assertions」セクションから始め、リンク先の assertj-examples リポジトリを調べて、現在の assertion の例を確認してください。カスタム例外 assertion が既存のクラス階層にどのように適合するかを確認し、例外メッセージと詳細フィールドを扱う例を両方の場所に記載してください。
索引モデルが issue の本文から書いたものです。
説明
Currently, the documentation shows how to extend an assertion in 2.6.2 Custom Assertions but there is no documentation for custom exception asserts, which seems to use a slightly different mechanism with some other class hierarchy.
It would be nice to include this in the guide and in the examples repository
The goal for this section in the guide will be to present, given a custom exception, a way to assert on the specific fields in that class. For instance, given a custom exception:
package com.example.exception;
public class DetailException extends RuntimeException {
private String detail;
public DetailException(String message, String detail) {
super(message);
this.detail = detail;
}
public String getDetail() {
return detail;
}
}
and a business logic throwing this exception
package com.example.thrower;
import com.example.exception.DetailException;
public class DetailExceptionThrower {
public void throwException() {
throw new DetailException("message", "a detailed exception explanation");
}
}
write an extension to write a test like:
package com.example.thrower;
import org.junit.jupiter.api.Test;
import static org.assertj.extension.DetailExceptionAssertions.assertThatDetailException;
class DetailExceptionThrowerCustomAssertionTest {
private final DetailExceptionThrower underTest = new DetailExceptionThrower();
@Test
void test_customAssertion() {
assertThatDetailException()
.isThrownBy(underTest::throwException)
.withMessage("message")
.withDetail("a detailed exception explanation");
}
}
is it even possible to write an extension like this?
- 主要言語
- CSS
- スター
- 26
- フォーク
- 32
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
assertj/doc のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 2/5 半日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 52/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
agilepathway/label-checker#640 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
BasedHardware/omi#15662 · コメント 1 件 ·
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
amponce/archive-movie-browser#167 ·
-
user-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
Kong/developer.konghq.com#7316 ·