LoginSignup
8
8

More than 5 years have passed since last update.

Intellij IDEAにJUnitのLive templateを追加する。

Last updated at Posted at 2012-11-23

今回参考にしたのはこちら。
Adding a JUnit test template in IntelliJ IDEA

登録するテンプレートはこちら。

JUnit実践入門の付録B.6のテンプレートを参考にいたしました。

test - テストメソッド


@org.junit.Test
public void _$should_assert_a_behaviour$() throws Exception {
    // Setup
    // Exercise
    // Verify
}

setUp - 初期化メソッド


@org.junit.Before
public void setUp() throws Exception {
    // Setup
    $END$
}

tearDown - 後処理メソッド


@org.junit.After
public void tearDown() throws Exception {
    // After
    $END$
}

setUpClass - クラスの初期化メソッド


@org.junit.BeforeClass
public static void setUpClass() throws Exception {
    // Setup
    $END$
}

tearDownClass - クラスの後処理メソッド


@org.junit.AfterClass
public static void tearDownClass() throws Exception {
    // After
    $END$
}

when - ネストしたテストクラス


public static class _$test_context$の場合 {

    $END$
}

instantiation - インスタンス化テスト


public static class インスタンス化テスト {

    @org.junit.Test
    public void デフォルトコンストラクタ() throws Exception {
        // Exercise
        $class$ instance = new $class$();
        // Verify
        assertThat(instance, is(notNullValue()));
    }
    $END$
}
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8