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);
}
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());
}
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);
}
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;
}
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"));
}
Aggregations