Slide 41
Slide 41 text
JUnit4 (2/3)
! テスト結果が期待通りかどうかは
assertThat(actual, expected)
を使う
41
// この2つをstatic importしておく
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
...
// 使⽤例
assertThat(x, is(3));
assertThat(x, is(not(4)));
assertThat(myList, hasItem("3"));
˞ 参考: マイナビニュース
『速攻解説! JUnit 4.4 - 新アサーションメソッド「assertThat」の⽤途とは』
http://news.mynavi.jp/articles/2007/07/20/junit1/
Copyright © 2016, NTT Software Corporation.