Skip to content

Instantly share code, notes, and snippets.

@kodaitakahashi
Last active May 7, 2017 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kodaitakahashi/37f6d65a300bf252041410b4cbd84c06 to your computer and use it in GitHub Desktop.
Save kodaitakahashi/37f6d65a300bf252041410b4cbd84c06 to your computer and use it in GitHub Desktop.
public BasicSyntax{
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Test;
Main sut = null; // テスト対象となるクラスのインスタンス
@Before // 共通する前処理を記述
// 例
public void setUp(){
Main sut = new Main();
}
@Test //テストメソッドを定義する
// 例 int sum(int, int)という足し算をするメソッドの正常系テスト
public void 整数5と5を_sumに渡すと_10が返ってくる() throws Exception{
int actual = sut.sum(5, 5); // 実則値
int expected = 10; // 期待値
assertThat(actual, is(expected));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment