Search in sources :

Example 1 with ProviderParameters

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

the class JUnitPlatformProviderTests method usesClassNamesForXmlReport.

@Test
void usesClassNamesForXmlReport() throws TestSetFailedException, InvocationTargetException {
    String[] classNames = { "org.junit.platform.surefire.provider.JUnitPlatformProviderTests$Sub1Tests", "org.junit.platform.surefire.provider.JUnitPlatformProviderTests$Sub2Tests" };
    ProviderParameters providerParameters = providerParametersMock(Sub1Tests.class, Sub2Tests.class);
    JUnitPlatformProvider jUnitPlatformProvider = new JUnitPlatformProvider(providerParameters);
    TestsToRun testsToRun = newTestsToRun(Sub1Tests.class, Sub2Tests.class);
    invokeProvider(jUnitPlatformProvider, testsToRun);
    RunListener reporter = providerParameters.getReporterFactory().createReporter();
    ArgumentCaptor<ReportEntry> reportEntryArgumentCaptor = ArgumentCaptor.forClass(ReportEntry.class);
    verify(reporter, times(2)).testSucceeded(reportEntryArgumentCaptor.capture());
    List<ReportEntry> allValues = reportEntryArgumentCaptor.getAllValues();
    assertThat(allValues).extracting(ReportEntry::getSourceName).containsExactly(classNames);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) SimpleReportEntry(org.apache.maven.surefire.report.SimpleReportEntry) ReportEntry(org.apache.maven.surefire.report.ReportEntry) TestsToRun(org.apache.maven.surefire.util.TestsToRun) RunListener(org.apache.maven.surefire.report.RunListener) Test(org.junit.jupiter.api.Test)

Example 2 with ProviderParameters

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

the class JUnitPlatformProviderTests method parsesConfigurationParameters.

@Test
void parsesConfigurationParameters() {
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    // 
    when(providerParameters.getProviderProperties()).thenReturn(singletonMap(JUnitPlatformProvider.CONFIGURATION_PARAMETERS, "foo = true\nbar 42\rbaz: *\r\nqux: EOF"));
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertEquals(4, provider.configurationParameters.size());
    assertEquals("true", provider.configurationParameters.get("foo"));
    assertEquals("42", provider.configurationParameters.get("bar"));
    assertEquals("*", provider.configurationParameters.get("baz"));
    assertEquals("EOF", provider.configurationParameters.get("qux"));
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) Test(org.junit.jupiter.api.Test)

Example 3 with ProviderParameters

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

the class JUnitPlatformProviderTests method onlyExcludeTagsIsDeclared.

@Test
void onlyExcludeTagsIsDeclared() throws Exception {
    Map<String, String> properties = new HashMap<>();
    properties.put(JUnitPlatformProvider.EXCLUDE_TAGS, "tagOne, tagTwo");
    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 4 with ProviderParameters

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

the class JUnitPlatformProviderTests method filtersWithEmptyTagsAreNotRegistered.

@Test
void filtersWithEmptyTagsAreNotRegistered() throws Exception {
    Map<String, String> properties = new HashMap<>();
    // Here only tagOne is registered as a valid tag and other tags are ignored as they are empty
    properties.put(JUnitPlatformProvider.EXCLUDE_GROUPS, "tagOne,");
    properties.put(JUnitPlatformProvider.EXCLUDE_TAGS, "");
    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 5 with ProviderParameters

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

the class JUnitPlatformProviderTests method noFiltersAreCreatedIfTagsAreEmpty.

@Test
void noFiltersAreCreatedIfTagsAreEmpty() throws Exception {
    Map<String, String> properties = new HashMap<>();
    properties.put(JUnitPlatformProvider.INCLUDE_TAGS, "");
    properties.put(JUnitPlatformProvider.INCLUDE_GROUPS, "");
    ProviderParameters providerParameters = providerParametersMock(TestClass1.class);
    when(providerParameters.getProviderProperties()).thenReturn(properties);
    JUnitPlatformProvider provider = new JUnitPlatformProvider(providerParameters);
    assertEquals(0, provider.filters.length);
}
Also used : ProviderParameters(org.apache.maven.surefire.providerapi.ProviderParameters) HashMap(java.util.HashMap) 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