Search in sources :

Example 6 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method noFiltersAreCreatedIfNoPropertiesAreDeclared.

@Test
void noFiltersAreCreatedIfNoPropertiesAreDeclared() throws Exception {
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertEquals(0, provider.filters.length);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) Test(org.junit.jupiter.api.Test)

Example 7 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method verifyPreconditionViolationException.

private void verifyPreconditionViolationException(Map<String, String> properties) {
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    when(providerParameters.getProviderProperties()).thenReturn(properties);
    Throwable throwable = assertThrows(PreconditionViolationException.class, () -> new JUnitPlatformProvider(providerParameters));
    assertEquals(JUnitPlatformProvider.EXCEPTION_MESSAGE_BOTH_NOT_ALLOWED, throwable.getMessage());
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters)

Example 8 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method onlyGroupsIsDeclared.

@Test
void onlyGroupsIsDeclared() throws Exception {
    Map<String, String> properties = new HashMap<>();
    properties.put(JUnitPlatformProvider.INCLUDE_GROUPS, "groupOne, groupTwo");
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    when(providerParameters.getProviderProperties()).thenReturn(properties);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertEquals(1, provider.filters.length);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Example 9 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method providerParametersMock.

private static ProviderParameters providerParametersMock(RunListener runListener, TestListResolver testListResolver, Class<?>... testClasses) {
    TestsToRun testsToRun = newTestsToRun(testClasses);
    ScanResult scanResult = mock(ScanResult.class);
    when(scanResult.applyFilter(any(), any())).thenReturn(testsToRun);
    RunOrderCalculator runOrderCalculator = mock(RunOrderCalculator.class);
    when(runOrderCalculator.orderTestClasses(any())).thenReturn(testsToRun);
    ReporterFactory reporterFactory = mock(ReporterFactory.class);
    when(reporterFactory.createReporter()).thenReturn(runListener);
    TestRequest testRequest = mock(TestRequest.class);
    when(testRequest.getTestListResolver()).thenReturn(testListResolver);
    ProviderParameters providerParameters = mock(ProviderParameters.class);
    when(providerParameters.getScanResult()).thenReturn(scanResult);
    when(providerParameters.getRunOrderCalculator()).thenReturn(runOrderCalculator);
    when(providerParameters.getReporterFactory()).thenReturn(reporterFactory);
    when(providerParameters.getTestRequest()).thenReturn(testRequest);
    return providerParameters;
}
Also used : RunOrderCalculator(org.apache.maven.surefire.util.RunOrderCalculator) ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) ScanResult(org.apache.maven.surefire.util.ScanResult) ReporterFactory(org.apache.maven.surefire.report.ReporterFactory) TestsToRun(org.apache.maven.surefire.util.TestsToRun) TestRequest(org.apache.maven.surefire.testset.TestRequest)

Example 10 with ProviderParameters

use of org.apache.maven.surefire.providerapi.ProviderParameters in project junit5 by junit-team.

the class JUnitPlatformProviderTests method invokeThrowsForWrongForkTestSet.

@Test
void invokeThrowsForWrongForkTestSet() throws Exception {
    ProviderParameters providerParameters = providerParametersMock(Integer.class);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertThrows(IllegalArgumentException.class, () -> invokeProvider(provider, "wrong forkTestSet"));
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) Test(org.junit.jupiter.api.Test)

Aggregations

ProviderParameters (org.apache.maven.surefire.providerapi.ProviderParameters)15 Test (org.junit.jupiter.api.Test)12 HashMap (java.util.HashMap)5 RunListener (org.apache.maven.surefire.report.RunListener)2 SimpleReportEntry (org.apache.maven.surefire.report.SimpleReportEntry)2 TestsToRun (org.apache.maven.surefire.util.TestsToRun)2 Launcher (org.junit.platform.launcher.Launcher)2 TestExecutionSummary (org.junit.platform.launcher.listeners.TestExecutionSummary)2 ReportEntry (org.apache.maven.surefire.report.ReportEntry)1 ReporterFactory (org.apache.maven.surefire.report.ReporterFactory)1 TestListResolver (org.apache.maven.surefire.testset.TestListResolver)1 TestRequest (org.apache.maven.surefire.testset.TestRequest)1 RunOrderCalculator (org.apache.maven.surefire.util.RunOrderCalculator)1 ScanResult (org.apache.maven.surefire.util.ScanResult)1 InOrder (org.mockito.InOrder)1