I'm trying to use as little setup as possible to create an ambient for unit tests for my java code using JUnit Console Launcher.
Following the classes created for testing:
SumTest.java
import static org.junit.jupiter.api.Assertions.assertEquals;
public class SumTest {
@Test
public void sumTest() {
assertEquals(10, sum(1,0));
}
}
Sum.java
public class Sum {
public int sum(int a, int b) {
return a + b;
}
}
Command:
$ java -jar junit-platform-console-standalone-1.8.2.jar -o SumTest.java
Output:
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
╷
├─ JUnit Jupiter ✔
└─ JUnit Vintage ✔
Test run finished after 88 ms
[ 2 containers found ]
[ 0 containers skipped ]
[ 2 containers started ]
[ 0 containers aborted ]
[ 2 containers successful ]
[ 0 containers failed ]
[ 0 tests found ]
[ 0 tests skipped ]
[ 0 tests started ]
[ 0 tests aborted ]
[ 0 tests successful ]
[ 0 tests failed ]
I expected to have a falling test. But my test wasn't recognized.