Search in sources :

Example 1 with ConsoleOutputReceiver

use of org.apache.maven.surefire.report.ConsoleOutputReceiver in project junit5 by junit-team.

the class JUnitPlatformProviderTests method outputIsCaptured.

@Test
void outputIsCaptured() throws Exception {
    Launcher launcher = LauncherFactory.create();
    RunListener runListener = runListenerMock();
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParametersMock(runListener), launcher);
    invokeProvider(provider, VerboseTestClass.class);
    ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
    // @formatter:off
    verify((ConsoleOutputReceiver) runListener).writeTestOutput(captor.capture(), eq(0), gt(6), eq(true));
    verify((ConsoleOutputReceiver) runListener).writeTestOutput(captor.capture(), eq(0), gt(6), eq(false));
    assertThat(captor.getAllValues()).extracting(bytes -> new String(bytes, 0, 6)).containsExactly("stdout", "stderr");
// @formatter:on
}
Also used : Arrays(java.util.Arrays) TestPlan(org.junit.platform.launcher.TestPlan) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ScanResult(org.apache.maven.surefire.util.ScanResult) Disabled(org.junit.jupiter.api.Disabled) TestsToRun(org.apache.maven.surefire.util.TestsToRun) TestExecutionSummary(org.junit.platform.launcher.listeners.TestExecutionSummary) Map(java.util.Map) RunListener(org.apache.maven.surefire.report.RunListener) LauncherFactory(org.junit.platform.launcher.core.LauncherFactory) TestListResolver(org.apache.maven.surefire.testset.TestListResolver) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) Failure(org.junit.platform.launcher.listeners.TestExecutionSummary.Failure) ConsoleOutputReceiver(org.apache.maven.surefire.report.ConsoleOutputReceiver) RunOrderCalculator(org.apache.maven.surefire.util.RunOrderCalculator) InvocationTargetException(java.lang.reflect.InvocationTargetException) Test(org.junit.jupiter.api.Test) TestIdentifier(org.junit.platform.launcher.TestIdentifier) SummaryGeneratingListener(org.junit.platform.launcher.listeners.SummaryGeneratingListener) List(java.util.List) TestRequest(org.apache.maven.surefire.testset.TestRequest) Mockito.inOrder(org.mockito.Mockito.inOrder) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) Mockito.withSettings(org.mockito.Mockito.withSettings) Mockito.any(org.mockito.Mockito.any) Mockito.eq(org.mockito.Mockito.eq) Mockito.mock(org.mockito.Mockito.mock) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) ReportEntry(org.apache.maven.surefire.report.ReportEntry) Launcher(org.junit.platform.launcher.Launcher) HashMap(java.util.HashMap) TestSetFailedException(org.apache.maven.surefire.testset.TestSetFailedException) ArrayList(java.util.ArrayList) ArgumentCaptor(org.mockito.ArgumentCaptor) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) Collections.singletonMap(java.util.Collections.singletonMap) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LinkedHashSet(java.util.LinkedHashSet) PrintStream(java.io.PrintStream) Collections.emptyMap(java.util.Collections.emptyMap) InOrder(org.mockito.InOrder) ReporterFactory(org.apache.maven.surefire.report.ReporterFactory) AdditionalMatchers.gt(org.mockito.AdditionalMatchers.gt) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) PreconditionViolationException(org.junit.platform.commons.util.PreconditionViolationException) Launcher(org.junit.platform.launcher.Launcher) ConsoleOutputReceiver(org.apache.maven.surefire.report.ConsoleOutputReceiver) RunListener(org.apache.maven.surefire.report.RunListener) Test(org.junit.jupiter.api.Test)

Aggregations

PrintStream (java.io.PrintStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singletonMap (java.util.Collections.singletonMap)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)1 ConsoleOutputReceiver (org.apache.maven.surefire.report.ConsoleOutputReceiver)1 ReportEntry (org.apache.maven.surefire.report.ReportEntry)1 ReporterFactory (org.apache.maven.surefire.report.ReporterFactory)1 RunListener (org.apache.maven.surefire.report.RunListener)1 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)1 TestListResolver (org.apache.maven.surefire.testset.TestListResolver)1 TestRequest (org.apache.maven.surefire.testset.TestRequest)1