Search in sources :

Example 1 with CommandLineOptionsParser

use of org.junit.platform.console.options.CommandLineOptionsParser in project junit5 by junit-team.

the class ConsoleLauncher method execute.

@API(status = INTERNAL, since = "1.0")
public static ConsoleLauncherExecutionResult execute(PrintStream out, PrintStream err, String... args) {
    CommandLineOptionsParser parser = new JOptSimpleCommandLineOptionsParser();
    ConsoleLauncher consoleLauncher = new ConsoleLauncher(parser, out, err);
    return consoleLauncher.execute(args);
}
Also used : JOptSimpleCommandLineOptionsParser(org.junit.platform.console.options.JOptSimpleCommandLineOptionsParser) CommandLineOptionsParser(org.junit.platform.console.options.CommandLineOptionsParser) JOptSimpleCommandLineOptionsParser(org.junit.platform.console.options.JOptSimpleCommandLineOptionsParser) API(org.apiguardian.api.API)

Example 2 with CommandLineOptionsParser

use of org.junit.platform.console.options.CommandLineOptionsParser in project junit5 by junit-team.

the class ConsoleLauncherTests method executeWithUnknownCommandLineOption.

@Test
void executeWithUnknownCommandLineOption() {
    CommandLineOptionsParser commandLineOptionsParser = mock(CommandLineOptionsParser.class);
    when(commandLineOptionsParser.parse(any())).thenReturn(new CommandLineOptions());
    ConsoleLauncher consoleLauncher = new ConsoleLauncher(commandLineOptionsParser, printSink, printSink);
    int exitCode = consoleLauncher.execute("--all").getExitCode();
    assertEquals(-1, exitCode);
    verify(commandLineOptionsParser).parse("--all");
}
Also used : CommandLineOptionsParser(org.junit.platform.console.options.CommandLineOptionsParser) CommandLineOptions(org.junit.platform.console.options.CommandLineOptions) Test(org.junit.jupiter.api.Test)

Example 3 with CommandLineOptionsParser

use of org.junit.platform.console.options.CommandLineOptionsParser in project junit5 by junit-team.

the class ConsoleLauncherTests method executeWithSupportedCommandLineOption.

@Test
void executeWithSupportedCommandLineOption() {
    CommandLineOptionsParser commandLineOptionsParser = mock(CommandLineOptionsParser.class);
    when(commandLineOptionsParser.parse(any())).thenReturn(new CommandLineOptions());
    ConsoleLauncher consoleLauncher = new ConsoleLauncher(commandLineOptionsParser, printSink, printSink);
    int exitCode = consoleLauncher.execute("--scan-classpath").getExitCode();
    assertEquals(-1, exitCode);
    verify(commandLineOptionsParser).parse("--scan-classpath");
}
Also used : CommandLineOptionsParser(org.junit.platform.console.options.CommandLineOptionsParser) CommandLineOptions(org.junit.platform.console.options.CommandLineOptions) Test(org.junit.jupiter.api.Test)

Example 4 with CommandLineOptionsParser

use of org.junit.platform.console.options.CommandLineOptionsParser in project junit5 by junit-team.

the class ConsoleLauncherTests method displayHelp.

@Test
void displayHelp() {
    CommandLineOptions options = new CommandLineOptions();
    options.setDisplayHelp(true);
    CommandLineOptionsParser commandLineOptionsParser = mock(CommandLineOptionsParser.class);
    when(commandLineOptionsParser.parse(any())).thenReturn(options);
    ConsoleLauncher consoleLauncher = new ConsoleLauncher(commandLineOptionsParser, printSink, printSink);
    int exitCode = consoleLauncher.execute("--help").getExitCode();
    assertEquals(0, exitCode);
    verify(commandLineOptionsParser).parse("--help");
}
Also used : CommandLineOptionsParser(org.junit.platform.console.options.CommandLineOptionsParser) CommandLineOptions(org.junit.platform.console.options.CommandLineOptions) Test(org.junit.jupiter.api.Test)

Aggregations

CommandLineOptionsParser (org.junit.platform.console.options.CommandLineOptionsParser)4 Test (org.junit.jupiter.api.Test)3 CommandLineOptions (org.junit.platform.console.options.CommandLineOptions)3 API (org.apiguardian.api.API)1 JOptSimpleCommandLineOptionsParser (org.junit.platform.console.options.JOptSimpleCommandLineOptionsParser)1