Tibor17 commented on a change in pull request #445: URL: https://github.com/apache/maven-surefire/pull/445#discussion_r793364036
########## File path: maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoProvidersInfoTest.java ########## @@ -0,0 +1,172 @@ +package org.apache.maven.plugin.surefire; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.surefire.providerapi.ProviderInfo; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +import static org.fest.assertions.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +/** + * Testing providerInfo applicable behavior. + */ +@RunWith( MockitoJUnitRunner.class ) +public class AbstractSurefireMojoProvidersInfoTest +{ + + @Spy + private AbstractSurefireMojo mojo; + + @Test + public void defaultProviderAreAlwaysAvailable() + { + ProviderInfo providerInfo = mojo.new JUnit3ProviderInfo(); + assertThat( providerInfo.isApplicable() ).isTrue(); + } + + @Test + public void dynamicProviderAreAlwaysApplicable() + { + ProviderInfo providerInfo = mojo.new DynamicProviderInfo( "test" ); + assertThat( providerInfo.isApplicable() ).isTrue(); + } + + @Test + public void testNgProviderApplicable() + { + Artifact testNg = mock( Artifact.class ); + ProviderInfo providerInfo = mojo.new TestNgProviderInfo( testNg ); + + assertThat( providerInfo.isApplicable() ).isTrue(); + + // no interaction with artifact only reference are checked + verifyNoMoreInteractions( testNg ); + } + + @Test + public void testNgProviderNotApplicable() + { + ProviderInfo providerInfo = mojo.new TestNgProviderInfo( null ); + assertThat( providerInfo.isApplicable() ).isFalse(); + } + + //surefire-junit-platform + + @Test + public void jUnitPlatformProviderApplicable() + { + Artifact junitPlatform = mock( Artifact.class ); + ProviderInfo providerInfo = mojo.new JUnitPlatformProviderInfo( junitPlatform, aTestClassPath() ); Review comment: It would be great to have unit tests for `JUnitPlatformProviderInfo` because the method `getProviderClasspath()` is not covered by unit tests, only covered by ITs. The [documentation](https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html) describes the behavior and the provider classpath is always resolved to necessary libraries including API and junit5 impl libraries. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org