You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/01/27 12:00:15 UTC

[GitHub] [maven-surefire] slawekjaranowski commented on a change in pull request #445: [SUREFIRE-1962] Unit test for ProviderInfo#isApplicable

slawekjaranowski commented on a change in pull request #445:
URL: https://github.com/apache/maven-surefire/pull/445#discussion_r793536350



##########
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 should be done is separate PR - many cases for ``getProviderClasspath`




-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org