You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andreas Pabst (Jira)" <ji...@apache.org> on 2022/12/29 11:43:00 UTC

[jira] [Commented] (SUREFIRE-2121) Failed to parse version of junit:junit: 4.13.2

    [ https://issues.apache.org/jira/browse/SUREFIRE-2121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17652817#comment-17652817 ] 

Andreas Pabst commented on SUREFIRE-2121:
-----------------------------------------

This is not a bug, it's a configuration error.

If you want to run JUnit 4 tests with the JUnit 5 Vintage Engine, then you need to explicitly provide the junit-vintage-engine dependency, either as an additional dependency of the maven-surefire-plugin definition or as a test scope dependency in your project.

If you have junit 4.13.1 or 4.13.2 on the test classpath, then you need to provide the junit-vintage-engine dependency in at least version 5.7.0, like this:
{code:xml}
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M7</version>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                        <version>5.7.0</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
{code}
What JUnit 5 version the Surefire project uses internally for the junit-platform-launcher dependency in the surefire-junit-platform module doesn't change anything about that. Even if we would update that version, you would still run into the same problem if you provide the junit-vintage-engine in too old a version.

Admittedly, the Surefire configuration examples page could be a bit more up to date when it comes to the artifact versions used in the examples.

> Failed to parse version of junit:junit: 4.13.2
> ----------------------------------------------
>
>                 Key: SUREFIRE-2121
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2121
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: JUnit 5.x support
>    Affects Versions: 3.0.0-M7
>            Reporter: Václav Haisman
>            Priority: Major
>              Labels: patch, pull-request-available
>
> I am getting the following error in some of my projects:
> {code}
> WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
> org.junit.platform.commons.JUnitException: Failed to parse version of junit:junit: 4.13.2
>         at org.junit.vintage.engine.JUnit4VersionCheck.parseVersion(JUnit4VersionCheck.java:54)
>         at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:37)
>         at org.junit.vintage.engine.JUnit4VersionCheck.checkSupported(JUnit4VersionCheck.java:32)
>         at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:61)
>         at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:177)
>         at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:164)
>         at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:120)
>         at org.apache.maven.surefire.junitplatform.LazyLauncher.discover(LazyLauncher.java:48)
>         at org.apache.maven.surefire.junitplatform.TestPlanScannerFilter.accept(TestPlanScannerFilter.java:56)
>         at org.apache.maven.surefire.api.util.DefaultScanResult.applyFilter(DefaultScanResult.java:102)
>         at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.scanClasspath(JUnitPlatformProvider.java:167)
>         at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:139)
>         at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:456)
>         at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:169)
>         at org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:595)
>         at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:581)
>  {code}
> I was able to reproduce this issue with the surefire-1585-junit4-vintage-it test when junit that it uses is upgraded to 4.13.2. The fix is to update JUnit5 Vintage engine.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)