insuficiencia compilación de prueba Maven

garg10may:

Acabo de crear un caso de prueba de ejemplo que funciona muy bien con la JUnitprueba. Me haga clic derecho en el proyecto y elegir run as --> JUnit test.

introducir descripción de la imagen aquí

Sin embargo, he añadido maven surefireplug-in para ejecutar la misma utilizando Maven. Pero run as --> Maven testfalla con el error más adelante.

 T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.416 s
[INFO] Finished at: 2020-03-29T20:40:40+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project idot: There are test failures.
[ERROR] 
[ERROR] Please refer to F:\coding\github\idot\idot-backend\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: org.junit.platform.launcher.TagFilter.includeTags(List)PostDiscoveryFilter/invokeStatic
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: org.junit.platform.launcher.TagFilter.includeTags(List)PostDiscoveryFilter/invokeStatic
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:656)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR]     at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR]     at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[ERROR]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
[ERROR]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
[ERROR]     at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR]     at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR]     at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
[ERROR]     at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
[ERROR]     at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[ERROR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[ERROR]     at java.lang.reflect.Method.invoke(Unknown Source)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR]     at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

pom.xml parte junit

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>

    <maven.compiler.target>8</maven.compiler.target>
    <maven.compiler.source>8</maven.compiler.source>
    <junit.jupiter.version>5.4.0</junit.jupiter.version>

</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Greenwich.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.5.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>${junit.jupiter.version}</version>
        <scope>test</scope>
    </dependency>
Datos no encontrados :

Si utiliza JUnit 5, hay un par de cosas que uno debe estar seguro:

  • Utilice la última versión de Eclipse (apoyo a JUnit 5 se añadió en oxígeno 1a , pero se debe utilizar la última, por ejemplo: 2020,03).
  • Usar al menos la versión 2.22.2 de maven-segura-plugin como se ve en JUnit 5 documentación aquí .
  • No especifique versión de sí mismo: usar el junit-bomen su dependencyManagementcomo usted ha hecho por spring-cloud-dependencies.
<dependencyManagement>
  <dependencies>    
    <dependency>
      <groupId>org.junit</groupId>
      <artifactId>junit-bom</artifactId>
      <version>5.6.1</version>
      <scope>import</scope> <type>pom</type>
    </dependency>
  </dependencies>
<dependencyManagement>

Lo racional es simple, y podría explicar su error: el uso de la junit-bom, que está seguro de que las dependencias que está utilizando se compilan en contra de la misma versión:

  • junit.jupiter.version es 5,4,0
  • junit-plataforma-lanzador es 1.5.1

Desde el centro , se puede observar que el motor está utilizando 1.4.0 de junit-platform-engine: que pueden estar introduciendo incompatibilidades para Maven build, lo que puede conducir al error que informó ( tal método: org.junit.platform.launcher.TagFilter.includeTags ( lista) PostDiscoveryFilter / invokeStatic ).

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=361732&siteId=1
Recomendado
Clasificación