You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2018/09/27 20:32:44 UTC

[maven-surefire] branch 1564 updated: fixed unit tests after refactoring of AbstractSurefireMojo

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch 1564
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/1564 by this push:
     new b8131cd  fixed unit tests after refactoring of AbstractSurefireMojo
b8131cd is described below

commit b8131cd62e717e407ad97238d0cd86b6bbc9af69
Author: Tibor17 <ti...@apache.org>
AuthorDate: Thu Sep 27 22:32:25 2018 +0200

    fixed unit tests after refactoring of AbstractSurefireMojo
---
 .../plugin/surefire/AbstractSurefireMojo.java      |  2 +-
 .../maven/plugin/surefire/TestClassPath.java       | 22 +-----
 .../AbstractSurefireMojoJava7PlusTest.java         | 74 +++++++++++++----
 .../plugin/surefire/AbstractSurefireMojoTest.java  | 92 +++++++++++++++++-----
 .../junitplatform/RunListenerAdapterTest.java      |  4 +-
 .../junitplatform/TestMethodFilterTest.java        |  5 +-
 6 files changed, 135 insertions(+), 64 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 905cdab..1a52dab 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -1793,7 +1793,7 @@ public abstract class AbstractSurefireMojo
             providerClasspath = ClasspathCache.setCachedClasspath( providerName, providerArtifacts );
         }
 
-        ResolvePathsRequest<String> req = ResolvePathsRequest.withStrings( testClasspath.getClassPath() )
+        ResolvePathsRequest<String> req = ResolvePathsRequest.ofStrings( testClasspath.getClassPath() )
                 .setMainModuleDescriptor( moduleDescriptor.getAbsolutePath() );
 
         ResolvePathsResult<String> result = ( (LocationManager) getLocationManager() ).resolvePaths( req );
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
index 6249ccd..d1b57d1 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
@@ -79,26 +79,6 @@ final class TestClassPath
         }
     }
 
-    Iterable<Artifact> getArtifacts()
-    {
-        return artifacts;
-    }
-
-    File getClassesDirectory()
-    {
-        return classesDirectory;
-    }
-
-    File getTestClassesDirectory()
-    {
-        return testClassesDirectory;
-    }
-
-    String[] getAdditionalClasspathElements()
-    {
-        return additionalClasspathElements;
-    }
-
     Classpath toClasspath()
     {
         List<String> classpath = new ArrayList<String>();
@@ -111,7 +91,7 @@ final class TestClassPath
                 File file = artifact.getFile();
                 if ( file != null )
                 {
-                    classpath.add( file.getPath() );
+                    classpath.add( file.getAbsolutePath() );
                 }
             }
         }
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index 8310fe3..96a2a5c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -20,6 +20,9 @@ package org.apache.maven.plugin.surefire;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
@@ -32,6 +35,7 @@ import org.apache.maven.surefire.util.DefaultScanResult;
 import org.codehaus.plexus.languages.java.jpms.LocationManager;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
+import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult.ModuleNameSource;
 import org.codehaus.plexus.logging.Logger;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -47,12 +51,13 @@ import java.nio.file.Path;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
-import static java.io.File.separatorChar;
 import static java.util.Arrays.asList;
 import static java.util.Collections.singleton;
 import static org.apache.commons.lang3.JavaVersion.JAVA_1_7;
 import static org.apache.commons.lang3.JavaVersion.JAVA_RECENT;
+import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
 import static org.apache.maven.surefire.booter.SystemUtils.isBuiltInJava7AtLeast;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.junit.Assume.assumeTrue;
@@ -78,6 +83,9 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
 public class AbstractSurefireMojoJava7PlusTest
 {
     @Mock
+    private ArtifactHandler handler;
+
+    @Mock
     private LocationManager locationManager;
 
     @BeforeClass
@@ -94,36 +102,62 @@ public class AbstractSurefireMojoJava7PlusTest
         doReturn( locationManager )
                 .when( mojo, "getLocationManager" );
 
-        Classpath testClasspath = new Classpath( asList( "non-modular.jar", "modular.jar",
-                "target" + separatorChar + "classes", "junit.jar", "hamcrest.jar" ) );
+        when( handler.isAddedToClasspath() ).thenReturn( true );
+
+        VersionRange v1 = createFromVersion( "1" );
+        Artifact modular = new DefaultArtifact( "x", "modular", v1, "compile", "jar", "", handler );
+        modular.setFile( mockFile( "modular.jar" ) );
+
+        VersionRange v2 = createFromVersion( "1" );
+        Artifact nonModular = new DefaultArtifact( "x", "non-modular", v2, "test", "jar", "", handler );
+        nonModular.setFile( mockFile( "non-modular.jar" ) );
+
+        VersionRange v3 = createFromVersion( "4.12" );
+        Artifact junit = new DefaultArtifact( "junit", "junit", v3, "test", "jar", "", handler );
+        junit.setFile( mockFile( "junit.jar" ) );
+
+        VersionRange v4 = createFromVersion( "1.3.0" );
+        Artifact hamcrest = new DefaultArtifact( "org.hamcrest", "hamcrest-core", v4, "test", "jar", "", handler );
+        hamcrest.setFile( mockFile( "hamcrest.jar" ) );
+
+        File classesDir = mockFile( "classes" );
+        File testClassesDir = mockFile( "test-classes" );
+
+        TestClassPath testClasspath =
+                new TestClassPath( asList( modular, nonModular, junit, hamcrest ), classesDir, testClassesDir,
+                        null, null );
 
         doReturn( testClasspath ).when( mojo, "generateTestClasspath" );
         doReturn( 1 ).when( mojo, "getEffectiveForkCount" );
         doReturn( true ).when( mojo, "effectiveIsEnableAssertions" );
         when( mojo.isChildDelegation() ).thenReturn( false );
-        when( mojo.getTestClassesDirectory() ).thenReturn( new File( "target" + separatorChar + "test-classes" ) );
+        when( mojo.getTestClassesDirectory() ).thenReturn( testClassesDir );
 
         DefaultScanResult scanResult = mock( DefaultScanResult.class );
         when( scanResult.getClasses() ).thenReturn( asList( "org.apache.A", "org.apache.B" ) );
 
         ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( false, true );
 
-        Classpath providerClasspath = new Classpath( singleton( "surefire-provider.jar" ) );
+        VersionRange v5 = createFromVersion( "1" );
+        Artifact provider = new DefaultArtifact( "org.apache.maven.surefire", "surefire-provider", v5, "runtime",
+                "jar", "", handler );
+        provider.setFile( mockFile( "surefire-provider.jar" ) );
+        Set<Artifact> providerClasspath = singleton( provider );
 
-        File moduleInfo = new File( "target" + separatorChar + "classes" + separatorChar + "module-info.class" );
+        File moduleInfo = mockFile( "classes/module-info.class" );
 
         @SuppressWarnings( "unchecked" )
         ResolvePathsRequest<String> req = mock( ResolvePathsRequest.class );
         mockStatic( ResolvePathsRequest.class );
-        when( ResolvePathsRequest.withStrings( eq( testClasspath.getClassPath() ) ) ).thenReturn( req );
+        when( ResolvePathsRequest.ofStrings( eq( testClasspath.toClasspath().getClassPath() ) ) ).thenReturn( req );
         when( req.setMainModuleDescriptor( eq( moduleInfo.getAbsolutePath() ) ) ).thenReturn( req );
 
         @SuppressWarnings( "unchecked" )
         ResolvePathsResult<String> res = mock( ResolvePathsResult.class );
         when( res.getClasspathElements() ).thenReturn( asList( "non-modular.jar", "junit.jar", "hamcrest.jar" ) );
-        Map<String, ResolvePathsResult.ModuleNameSource> mod = new LinkedHashMap<String, ResolvePathsResult.ModuleNameSource>();
+        Map<String, ModuleNameSource> mod = new LinkedHashMap<String, ModuleNameSource>();
         mod.put( "modular.jar", null );
-        mod.put( "target" + separatorChar + "classes", null );
+        mod.put( "classes", null );
         when( res.getModulepathElements() ).thenReturn( mod );
         when( locationManager.resolvePaths( eq( req ) ) ).thenReturn( res );
 
@@ -132,7 +166,7 @@ public class AbstractSurefireMojoJava7PlusTest
         doNothing().when( logger ).debug( anyString() );
         when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
 
-        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigForModularClasspath",
+        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigWithModularPath",
                 classLoaderConfiguration, providerClasspath, "org.asf.Provider", moduleInfo, scanResult );
 
         verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
@@ -142,7 +176,7 @@ public class AbstractSurefireMojoJava7PlusTest
         verify( mojo, times( 1 ) ).getTestClassesDirectory();
         verify( scanResult, times( 1 ) ).getClasses();
         verifyStatic( ResolvePathsRequest.class, times( 1 ) );
-        ResolvePathsRequest.withStrings( eq( testClasspath.getClassPath() ) );
+        ResolvePathsRequest.ofStrings( eq( testClasspath.toClasspath().getClassPath() ) );
         verify( req, times( 1 ) ).setMainModuleDescriptor( eq( moduleInfo.getAbsolutePath() ) );
         verify( res, times( 1 ) ).getClasspathElements();
         verify( res, times( 1 ) ).getModulepathElements();
@@ -151,7 +185,7 @@ public class AbstractSurefireMojoJava7PlusTest
         verify( logger, times( 6 ) ).debug( argument.capture() );
         assertThat( argument.getAllValues() )
                 .containsExactly( "test classpath:  non-modular.jar  junit.jar  hamcrest.jar",
-                        "test modulepath:  modular.jar  target" + separatorChar + "classes",
+                        "test modulepath:  modular.jar  classes",
                         "provider classpath:  surefire-provider.jar",
                         "test(compact) classpath:  non-modular.jar  junit.jar  hamcrest.jar",
                         "test(compact) modulepath:  modular.jar  classes",
@@ -168,15 +202,16 @@ public class AbstractSurefireMojoJava7PlusTest
         assertThat( conf.getClasspathConfiguration() ).isNotNull();
         assertThat( ( Object ) conf.getClasspathConfiguration().getTestClasspath() )
                 .isEqualTo( new Classpath( res.getClasspathElements() ) );
-        assertThat( ( Object ) conf.getClasspathConfiguration().getProviderClasspath() ).isSameAs( providerClasspath );
+        assertThat( ( Object ) conf.getClasspathConfiguration().getProviderClasspath() )
+                .isEqualTo( new Classpath( singleton( "surefire-provider.jar" ) ) );
         assertThat( conf.getClasspathConfiguration() ).isInstanceOf( ModularClasspathConfiguration.class );
         ModularClasspathConfiguration mcc = ( ModularClasspathConfiguration ) conf.getClasspathConfiguration();
         assertThat( mcc.getModularClasspath().getModuleDescriptor() ).isEqualTo( moduleInfo );
         assertThat( mcc.getModularClasspath().getPackages() ).containsOnly( "org.apache" );
-        assertThat( mcc.getModularClasspath().getPatchFile() )
-                .isEqualTo( new File( "target" + separatorChar + "test-classes" ) );
+        assertThat( mcc.getModularClasspath().getPatchFile().getAbsolutePath() )
+                .isEqualTo( "test-classes" );
         assertThat( mcc.getModularClasspath().getModulePath() )
-                .containsExactly( "modular.jar", "target" + separatorChar + "classes" );
+                .containsExactly( "modular.jar", "classes" );
         assertThat( ( Object ) mcc.getTestClasspath() ).isEqualTo( new Classpath( res.getClasspathElements() ) );
     }
 
@@ -222,6 +257,13 @@ public class AbstractSurefireMojoJava7PlusTest
                 .isTrue();
     }
 
+    private static File mockFile( String absolutePath )
+    {
+        File f = mock( File.class );
+        when( f.getAbsolutePath() ).thenReturn( absolutePath );
+        return f;
+    }
+
     public static class Mojo
             extends AbstractSurefireMojo
     {
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index 481d91e..417d632 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -20,7 +20,9 @@ package org.apache.maven.plugin.surefire;
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
 import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.surefire.log.PluginConsoleLogger;
@@ -33,23 +35,28 @@ import org.codehaus.plexus.logging.Logger;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import static java.io.File.separatorChar;
 import static java.util.Arrays.asList;
 import static java.util.Collections.singleton;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
+import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.verify;
@@ -67,6 +74,9 @@ import static org.powermock.reflect.Whitebox.invokeMethod;
 @PrepareForTest( AbstractSurefireMojo.class )
 public class AbstractSurefireMojoTest
 {
+    @Mock
+    private ArtifactHandler handler;
+
     private final Mojo mojo = new Mojo();
 
     @Test
@@ -121,21 +131,19 @@ public class AbstractSurefireMojoTest
         when( project.getArtifacts() ).thenReturn( artifacts );
         when( mojo.getProject() ).thenReturn( project );
 
-        Classpath cp = invokeMethod( mojo, "generateTestClasspath" );
+        TestClassPath cp = invokeMethod( mojo, "generateTestClasspath" );
 
         verifyPrivate( mojo, times( 1 ) ).invoke( "generateTestClasspath" );
         verify( mojo, times( 1 ) ).getClassesDirectory();
         verify( mojo, times( 1 ) ).getTestClassesDirectory();
         verify( mojo, times( 3 ) ).getClasspathDependencyScopeExclude();
         verify( mojo, times( 2 ) ).getClasspathDependencyExcludes();
-        verify( artifactHandler, times( 1 ) ).isAddedToClasspath();
-        verifyPrivate( mojo, times( 1 ) ).invoke( "getTestNgArtifact" );
-        verifyPrivate( mojo, times( 1 ) ).invoke( "addTestNgUtilsArtifacts", eq( cp.getClassPath() ) );
-
-        assertThat( cp.getClassPath() ).hasSize( 3 );
-        assertThat( cp.getClassPath().get( 0 ) ).endsWith( "test-classes" );
-        assertThat( cp.getClassPath().get( 1 ) ).endsWith( "classes" );
-        assertThat( cp.getClassPath().get( 2 ) ).endsWith( "a2-2.jar" );
+        verify( mojo, times( 1 ) ).getAdditionalClasspathElements();
+
+        assertThat( cp.toClasspath().getClassPath() ).hasSize( 3 );
+        assertThat( cp.toClasspath().getClassPath().get( 0 ) ).endsWith( "classes" );
+        assertThat( cp.toClasspath().getClassPath().get( 1 ) ).endsWith( "test-classes" );
+        assertThat( cp.toClasspath().getClassPath().get( 2 ) ).endsWith( "a2-2.jar" );
     }
 
     @Test
@@ -143,7 +151,37 @@ public class AbstractSurefireMojoTest
             throws Exception
     {
         AbstractSurefireMojo mojo = spy( this.mojo );
-        Classpath testClasspath = new Classpath( asList( "junit.jar", "hamcrest.jar" ) );
+
+        Artifact common = new DefaultArtifact( "org.apache.maven.surefire", "maven-surefire-common",
+                createFromVersion( "1" ), "runtime", "jar", "", handler );
+        common.setFile( mockFile( "maven-surefire-common.jar" ) );
+
+
+        Artifact api = new DefaultArtifact( "org.apache.maven.surefire", "surefire-api",
+                createFromVersion( "1" ), "runtime", "jar", "", handler );
+        api.setFile( mockFile( "surefire-api.jar" ) );
+
+        Map<String, Artifact> providerArtifactsMap = new HashMap<String, Artifact>();
+        providerArtifactsMap.put( "org.apache.maven.surefire:maven-surefire-common", common );
+        providerArtifactsMap.put( "org.apache.maven.surefire:surefire-api", api );
+
+        when( mojo.getPluginArtifactMap() )
+                .thenReturn( providerArtifactsMap );
+
+        when( handler.isAddedToClasspath() ).thenReturn( true );
+
+        VersionRange v1 = createFromVersion( "4.12" );
+        Artifact junit = new DefaultArtifact( "junit", "junit", v1, "test", "jar", "", handler );
+        junit.setFile( mockFile( "junit.jar" ) );
+
+        VersionRange v2 = createFromVersion( "1.3.0" );
+        Artifact hamcrest = new DefaultArtifact( "org.hamcrest", "hamcrest-core", v2, "test", "jar", "", handler );
+        hamcrest.setFile( mockFile( "hamcrest.jar" ) );
+
+        File classesDir = mockFile( "classes" );
+        File testClassesDir = mockFile( "test-classes" );
+        TestClassPath testClasspath =
+                new TestClassPath( asList( junit, hamcrest ), classesDir, testClassesDir, null, null );
 
         doReturn( testClasspath ).when( mojo, "generateTestClasspath" );
         doReturn( 1 ).when( mojo, "getEffectiveForkCount" );
@@ -152,18 +190,18 @@ public class AbstractSurefireMojoTest
 
         ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( false, true );
 
-        Classpath providerClasspath = new Classpath( singleton( "surefire-provider.jar" ) );
-
-        Classpath inprocClasspath =
-                new Classpath( asList( "surefire-api.jar", "surefire-common.jar", "surefire-provider.jar" ) );
+        VersionRange v3 = createFromVersion( "1" );
+        Artifact provider = new DefaultArtifact( "x", "surefire-provider", v3, "runtime", "jar", "", handler );
+        provider.setFile( mockFile( "surefire-provider.jar" ) );
+        Set<Artifact> providerArtifacts = singleton( provider );
 
         Logger logger = mock( Logger.class );
         when( logger.isDebugEnabled() ).thenReturn( true );
         doNothing().when( logger ).debug( anyString() );
         when( mojo.getConsoleLogger() ).thenReturn( new PluginConsoleLogger( logger ) );
 
-        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigForNonModularClasspath",
-                classLoaderConfiguration, providerClasspath, inprocClasspath, "org.asf.Provider" );
+        StartupConfiguration conf = invokeMethod( mojo, "newStartupConfigWithClasspath",
+                classLoaderConfiguration, providerArtifacts, "org.asf.Provider" );
 
         verify( mojo, times( 1 ) ).effectiveIsEnableAssertions();
         verify( mojo, times( 1 ) ).isChildDelegation();
@@ -173,9 +211,9 @@ public class AbstractSurefireMojoTest
         ArgumentCaptor<String> argument = ArgumentCaptor.forClass( String.class );
         verify( logger, times( 4 ) ).debug( argument.capture() );
         assertThat( argument.getAllValues() )
-                .containsExactly( "test classpath:  junit.jar  hamcrest.jar",
+                .containsExactly( "test classpath:  classes  test-classes  junit.jar  hamcrest.jar",
                         "provider classpath:  surefire-provider.jar",
-                        "test(compact) classpath:  junit.jar  hamcrest.jar",
+                        "test(compact) classpath:  classes  test-classes  junit.jar  hamcrest.jar",
                         "provider(compact) classpath:  surefire-provider.jar"
                 );
 
@@ -183,10 +221,15 @@ public class AbstractSurefireMojoTest
                 .isSameAs( classLoaderConfiguration );
 
         assertThat( ( Object ) conf.getClasspathConfiguration().getTestClasspath() )
-                .isSameAs( testClasspath );
+                .isEqualTo( testClasspath.toClasspath() );
 
+        Collection<String> files = new ArrayList<String>();
+        for ( Artifact providerArtifact : providerArtifacts )
+        {
+            files.add( providerArtifact.getFile().getAbsolutePath() );
+        }
         assertThat( ( Object ) conf.getClasspathConfiguration().getProviderClasspath() )
-                .isSameAs( providerClasspath );
+                .isEqualTo( new Classpath( files ) );
 
         assertThat( ( Object ) conf.getClasspathConfiguration().isClassPathConfig() )
                 .isEqualTo( true );
@@ -602,4 +645,11 @@ public class AbstractSurefireMojoTest
             return null;
         }
     }
+
+    private static File mockFile( String absolutePath )
+    {
+        File f = mock( File.class );
+        when( f.getAbsolutePath() ).thenReturn( absolutePath );
+        return f;
+    }
 }
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
index 5fa9bad..0ccb4fe 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
@@ -69,7 +69,7 @@ import org.mockito.InOrder;
  */
 public class RunListenerAdapterTest
 {
-    private static final ConfigurationParameters configParams = mock(ConfigurationParameters.class);
+    private static final ConfigurationParameters CONFIG_PARAMS = mock(ConfigurationParameters.class);
 
     private RunListener listener;
 
@@ -447,7 +447,7 @@ public class RunListenerAdapterTest
 
     private static TestDescriptor newClassDescriptor()
     {
-        return new ClassTestDescriptor( UniqueId.root( "class", MyTestClass.class.getName() ), MyTestClass.class, configParams );
+        return new ClassTestDescriptor( UniqueId.root( "class", MyTestClass.class.getName() ), MyTestClass.class, CONFIG_PARAMS );
     }
 
     private static TestIdentifier newSourcelessChildIdentifierWithParent(
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
index aeb86a7..6d4394e 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
@@ -42,8 +42,7 @@ import org.junit.platform.engine.UniqueId;
  */
 public class TestMethodFilterTest
 {
-
-    private static final ConfigurationParameters configParams = mock(ConfigurationParameters.class);
+    private static final ConfigurationParameters CONFIG_PARAMS = mock(ConfigurationParameters.class);
 
     private final TestListResolver resolver = mock( TestListResolver.class );
 
@@ -94,7 +93,7 @@ public class TestMethodFilterTest
     private static ClassTestDescriptor newClassTestDescriptor()
     {
         UniqueId uniqueId = UniqueId.forEngine( "class" );
-        return new ClassTestDescriptor( uniqueId, TestClass.class, configParams );
+        return new ClassTestDescriptor( uniqueId, TestClass.class, CONFIG_PARAMS );
     }
 
     public static class TestClass