Pixel Pedals of Tomakomai

北海道苫小牧市出身の初老の日常

plain-old jarで JUnit5 を試す

https://junit.org/junit5/docs/current/user-guide/#running-tests-console-launcher に書いてあるんだけど、分かりにく過ぎたので。

$ curl -O https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/1.5.2/junit-platform-console-standalone-1.5.2.jar
$ cat SampleTest.java
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

public class SampleTest {
    @Test
    public void testOneEqualsOne() {
        assertEquals(1, 1);
    }
}
$ javac -cp junit-platform-console-standalone-1.5.2.jar:. *.java
$ java -jar junit-platform-console-standalone-1.5.2.jar -cp . --scan-classpath

Thanks for using JUnit! Support its development at https://junit.org/sponsoring

╷
├─ JUnit Jupiter ✔
│  └─ SampleTest ✔
│     └─ testOneEqualsOne() ✔
└─ JUnit Vintage ✔

Test run finished after 169 ms
[         3 containers found      ]
[         0 containers skipped    ]
[         3 containers started    ]
[         0 containers aborted    ]
[         3 containers successful ]
[         0 containers failed     ]
[         1 tests found           ]
[         0 tests skipped         ]
[         1 tests started         ]
[         0 tests aborted         ]
[         1 tests successful      ]
[         0 tests failed          ]