[Eclipse]JUnit5のテストを実施する方法

環境
Eclipse 4.14.0
Junit4
WIndows 10 64bit

操作方法
1.メインプログラムの作成

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study;
public class StrUtil {
public static boolean isEmpty(String str) {
if ( str == null || str.length() == 0 )
return true;
return false;
}
}
package com.arkgame.study; public class StrUtil { public static boolean isEmpty(String str) { if ( str == null || str.length() == 0 ) return true; return false; } }
package com.arkgame.study;

public class StrUtil {

      public static boolean isEmpty(String str) {
          if ( str == null || str.length() == 0 )
            return true;
          return false;
        }
}

2.テストプログラムの作成

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
package com.arkgame.study;
import org.junit.jupiter.api.Test;
public class StrDemoTest {
@Test
public void isEmptyConfirm() {
System.out.println(StrUtil.isEmpty("study"));
}
}
package com.arkgame.study; import org.junit.jupiter.api.Test; public class StrDemoTest { @Test public void isEmptyConfirm() { System.out.println(StrUtil.isEmpty("study")); } }
package com.arkgame.study;

import org.junit.jupiter.api.Test;

public class StrDemoTest {

        @Test
        public void isEmptyConfirm() {
          System.out.println(StrUtil.isEmpty("study"));
        }
}

@Testのアノテーションに「JUnit 5 ライブラリーをビルド・パスに追加」を追加します.

3.JUnitでテストを実行します
テストプログラムを右クリックし、「Junitテスト」をクリックします。
コンソール画面にfalseが表示されます。

Eclipse

Posted by arkgame