我在一个项目中混合了单元测试框架(用于surefire maven插件):JUnit TestNG(几乎所有测试都是JUnit测试,但TestNG包含在两个测试所需的反应流TCK框架中。所有集成测试(故障保护)都只是JUnit测试。我成功地将surefire配置为使用以下插件配置运行两个测试:JUnit和TestNG:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>surefire-testng</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include><!-- test one --></include>
<include><!-- test two --></include>
</includes>
<junitArtifactName>none:none</junitArtifactName>
</configuration>
</execution>
<execution>
<id>surefire-junit</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<excludes>
<exclude><!-- test one --></exclude>
<exclude><!-- test two --></exclude>
</excludes>
<testNGArtifactName>none:none</testNGArtifactName>
</configuration>
</execution>
</executions>
</plugin>
当我运行mvn测试时,这个配置运行得很好。
但是当我尝试运行
mvn验证
来检查故障安全测试时,Maven失败并出错:
[ERROR] org.apache.maven.surefire.booter.SurefireExecutionException: Exception in provider
[ERROR] at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:91)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1198)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1063)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:889)
[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:957)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[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] Caused by: java.lang.NoSuchMethodError: 'void org.testng.xml.XmlSuite.setParallel(java.lang.String)'
[ERROR] at org.apache.maven.surefire.testng.conf.TestNGMapConfigurator.configure(TestNGMapConfigurator.java:71)
[ERROR] at org.apache.maven.surefire.testng.conf.TestNG510Configurator.configure(TestNG510Configurator.java:40)
[ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:110)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:112)
[ERROR] at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:99)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:146)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:186)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:161)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:84)
[ERROR] at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:87)
[ERROR] ... 25 more
[ERROR] -> [Help 1]
完整的源代码和插件配置可在这里:https://github.com/artipie/http/tree/multipart
在故障保护插件中禁用TestNG并仅将其保存在surefire中的正确方法是什么?
您可以手动强制指定提供者JUnit到maven-故障安全插件
,然后从全局依赖标记中删除testng
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<!-- <parallel>none</parallel> -->
<trimStackTrace>false</trimStackTrace>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
我将使用诱惑报告来监控硒测试结果。我正在使用TestNG和Maven failsafe插件来运行测试。我找到了非常清晰的例子来修改pom。xml,以便在您使用Maven surefire插件时包含case的诱惑,但对Maven failsafe插件则没有。我假设配置应该非常相似,但它不适合我。这是我pom里的东西。xml: 这是我看到的错误: 任何建议都将不胜感激。我假设配置Maven故障保护插件
Maven Surefire和Maven故障保护插件之间有什么区别<我在网上到处搜索,但没有找到答案。
在我的项目中,我创建了以下目录结构 在我的pom.xml我做了以下记录 如果我复制src中的资源- 如何使联调也将资源中的文件复制到目标中?
我想使用maven-故障安全插件来运行一些集成测试。如果任何测试失败,我希望Maven构建失败而不是构建成功。 我如何配置它,构建不成功是什么? 我的故障保护插件配置为:
我正在运行spring boot,KafkaListener是我的客户。问题是我们如何从失败的kafka配置中恢复,并避免应用程序在退出代码为0的过程结束时停止。例如,不正确的配置可能是不正确的endpointurl。如果无法访问Kafka服务器,也会出现同样的情况。因此,在任何情况下,KafkaListner进程都不应该杀死服务器。 ontext.java:895应用程序上下文异常:未能启动be
我有一个项目,其中我使用mavenplugin来运行集成测试。我使用的是框架组合。出于项目目的,我在前面修改了TestNG的默认XML报告,以自定义项目需求。 我在CustomReporter类中实现了上述要求,该类扩展了TestNG的接口。早些时候,我使用了插件来运行这些测试方法,并在surefire插件中添加了