maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tibor Digana (Jira)" <>
Subject [jira] [Commented] (SUREFIRE-1521) Replace PowerMock usage
Date Sat, 13 Jun 2020 15:10:00 GMT


Tibor Digana commented on SUREFIRE-1521:

I reported this issue in GH not because of Surefire but because this may help the other users.
The utility {{org.apache.maven.surefire.booter.SystemUtils}} is however final but the utilities
can be mocked by the version 2.0.5.
Hither versions are built, I think, with the j8.
We have jdk11, 14 in the build running without any issues.
The Powermock is great tool for mocking static classes, etc.
We have so many tests that I would not have any doubts.

Currently this issues seems to be fixed and we have the mock of final class Utility:

    @RunWith( PowerMockRunner.class )
    @PrepareForTest( SystemUtils.class )
    @PowerMockIgnore( { "org.jacoco.agent.rt.*", "com.vladium.emma.rt.*" } )
    public static class MockTest

        public void shouldBeDifferentJdk9()
            testIsJava9AtLeast( new File( System.getProperty( "java.home" ) ) );

        private static void testIsJava9AtLeast( File pathInJdk )
            File path = new File( pathInJdk, "bin" + separator + "java" );

            mockStatic( SystemUtils.class );

> Replace PowerMock usage
> -----------------------
>                 Key: SUREFIRE-1521
>                 URL:
>             Project: Maven Surefire
>          Issue Type: Dependency upgrade
>            Reporter: Christian Stein
>            Priority: Minor
>         Attachments: image-2018-05-08-20-03-42-257.png
> PowerMock seems not actively maintained. With the upcoming release of Java 11 this will
lead to problems. As can be seen here:
> We should replace the usage of it in only *4* of Surefires' tests by using `mockito`,
if possible. Or don't mock here at all and achieve the same test goals by using the real domain
model types. 
> !image-2018-05-08-20-03-42-257.png!

This message was sent by Atlassian Jira

View raw message