Similar stackoverflow posting: "JUnit 5 ConsoleLauncher doesn't work" answered Marc Philipp 13 March 2018.
I tried to duplicate the example posted in the above posting. The JUnit Test class is "DisplayNameDemo.java" shown below:
DisplayNameDemo.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@DisplayName("A special test case")
public class DisplayNameDemo {
@Test
@DisplayName("Custom test name containing spaces")
void testWithDisplayNameContainingSpaces() {
}
@Test
@DisplayName("╯°□°)╯")
void testWithDisplayNameContainingSpecialCharacters() {
}
@Test
@DisplayName(" ")
void testWithDisplayNameContainingEmoji() {
}
}
Here is my JUnit 5 command line command: "java -jar junit-platform-console-standalone-1.6.2.jar --classpath . --select-class DisplayNameDemo --include-classname '.*'"
This failed when I executed it, but passed when executed in the post. Here a partial of my failed result:
~/junit5.6.2/console$ java -jar junit-platform-console-standalone-1.6.2.jar --classpath . --select-class DisplayNameDemo --include-classname '.*'
Thanks for using JUnit! Support its development at https://junit.org/sponsoring
Usage: ConsoleLauncher [-h] [--disable-ansi-colors] [--disable-banner]
[--fail-if-no-tests] [--scan-modules] [--scan-classpath[=PATH[;|:
PATH...]]]... [--details=MODE] [--details-theme=THEME]
[--reports-dir=DIR] [-c=CLASS]... [--config=KEY=VALUE]... [-cp=PATH
I have all classes in the same directory as the junit-platform-console-standalone-1.6.2.jar file. I also have my classpath set to the local directory "." as shown above.
I cannot understand why this example fails. I would very much appreciate some help - especially from Marc Philipp or Sormuras on stackoverflow. Thanks for any help !