by shigemk2

当面は技術的なことしか書かない

JUnit

antコマンドだけでJUnitを実行する

流れ Eclipseでごにょごにょするのが嫌だったので。 AntでJUnit 4.10のテストを実行する - Symfoware ソースコードは↑のリンクを参照した。 以下ディレクトリ構成。 $ tree -a -I .git . ├── .gitignore ├── .travis.yml ├── README.md ├── build │ └── samp…

カスタムMatcherを作ろう

日付の比較検証を行うカスタムMatcherの要件 クラスを作成する ファクトリメソッドを作成する コンストラクタを定義する matchesメソッドを実装する describeToメソッドを実装する public class IsDate extends BaseMatcher<Date> { private final int yyyy; priva</date>…

assertThatを使うために

import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*;

assertThat

int expected = 7; int actual = add(3, 4); assertThat(actual, is(expected)); 検証コードが自然言語の表記に近くなる。