FEST-Assert 0.9:Javaのテストに「流れるようなインタフェース」を
Java向けテスト補助ライブラリ「FEST-Assert 0.9」を利用すると、「流れるようなインタフェース」でテストを記述することが可能になる。
FEST-Assert
http://fest.easytesting.org/assert/
これ良さそうですねぇ。
サンプルコードも以下のようになるらしい。
int removed = employees.removeFired(); assertThat(removed).isZero(); List<Employee> newEmployees = employees.hired(TODAY); assertThat(newEmployees).hasSize(6) .contains(frodo, sam); String[] newHires = employees.newHiresNames(); assertThat(newHires).containsOnly("Gandalf", "Arwen", "Gimli"); assertThat(yoda).isInstanceOf(Jedi.class) .isEqualTo(foundJedi) .isNotEqualTo(foundSith);
http://fest.easytesting.org/assert/extending.html
によると拡張してカスタムの流れるようなインターフェースも
容易に作成できる様子。