- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经解决了所有与SO相关的问题。但我认为我的问题与其他人的问题没什么不同。
我有以下套件 xml 文件
Initialize.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Start" verbose="1" parallel="tests"
thread-count="5" configfailurepolicy="continue">
<test name="Initialize" annotations="JDK" preserve-order="true">
<parameter name="tags" value="not @42" />
<classes>
<class name="com.example.runner.InitializeExecution" />
</classes>
</test>
</suite>
Conclusion.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Start" verbose="1" parallel="tests"
thread-count="5" configfailurepolicy="continue">
<test name="Conclude" annotations="JDK" preserve-order="true">
<parameter name="tags" value="not @42" />
<classes>
<class name="com.example.runner.ConcludeExecution" />
</classes>
</test>
</suite>
smoke.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="smoke" verbose="1" parallel="tests"
thread-count="3" configfailurepolicy="continue" data-provider-thread-count="2">
<test name="Smoke" annotations="JDK" preserve-order="true">
<parameter name="tags" value="@dm1" />
<classes>
<class name="com.example.runner.smoke" />
</classes>
</test>
</suite>
regression.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="smoke" verbose="1" parallel="tests"
thread-count="3" configfailurepolicy="continue" data-provider-thread-count="2">
<test name="Regression" annotations="JDK" preserve-order="true">
<parameter name="tags" value="@dm1" />
<classes>
<class name="com.example.runner.regression" />
</classes>
</test>
</suite>
pom.xml 片段
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<properties>
<property>
<name>dataproviderthreadcount</name>
<value>2</value>
</property>
</properties>
<suiteXmlFiles>
<suiteXmlFile>Initialize.xml</suiteXmlFile>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
<suiteXmlFile>Conclude.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<!-- <scope>compile</scope> -->
</dependency>
我需要按顺序执行initialize.xml,然后执行smoke.xml 或regression.xml,然后执行conclusion.xml。以以下集合为例:
<suiteXmlFiles>
<suiteXmlFile>Initialize.xml</suiteXmlFile>
<suiteXmlFile>smoke.xml</suiteXmlFile>
<!-- or -->
<!-- <suiteXmlFile>regression.xml</suiteXmlFile> -->
<suiteXmlFile>Conclude.xml</suiteXmlFile>
</suiteXmlFiles>
如何从 pom 参数化中间 suiteXmlFile?我尝试使用下面的命令,但它不起作用并抛出异常。
mvn clean test -Dsurefire.suiteXmlFile=smoke.test
[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:1132)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:978)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:854)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
[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:290)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] Caused by: java.lang.NullPointerException
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.locateTestSets(TestNGXmlTestSuite.java:97)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:119)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:206)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:160)
[ERROR] at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:83)
[ERROR] at org.apache.maven.plugin.surefire.InPluginVMSurefireStarter.runSuitesInProcess(InPluginVMSurefireStarter.java:87)
[ERROR] ... 25 more
[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
如果我使用下面的命令,它可以工作,但不会执行initialize.xml 和clusion.xml(注意命令中的s)
mvn clean test -Dsurefire.suiteXmlFiles=smoke.test
我还尝试创建如下所示的不同套件 xml 并通过命令行传递它,但它没有按我的预期工作。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Smoke Suite" >
<suite-files>
<suite-file path="./Initialize.xml" />
<suite-file path="./somke.xml" />
<suite-file path="./Conclude.xml" />
</suite-files>
</suite>
请帮忙。任何引用或有用的链接也表示赞赏。
最佳答案
我们可以做如下的事情吗,其中大部分您已经完成了:
<suiteXmlFiles>
<suiteXmlFile>Initialize.xml</suiteXmlFile>
<suiteXmlFile>${smokeORregression}</suiteXmlFile>
<suiteXmlFile>Conclude.xml</suiteXmlFile>
</suiteXmlFiles>
然后根据需要执行mvn clean test -DsmokeORregression=smoke.xml
或mvn clean test -DsmokeORregression=regression.xml
。
您不需要在 mvn 命令中使用 Surefire
。
关于java - 如何通过 Maven Surefire 插件运行选定的 suiteXmlFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61676131/
目前我有可能使用 surefire 插件在 maven 上运行多个测试,如下所示: mvn clean test -Dsurefire.suiteXmlFiles=test1.xml,test2.xm
我已经解决了所有与SO相关的问题。但我认为我的问题与其他人的问题没什么不同。 我有以下套件 xml 文件 Initialize.xml
我有一个非常简单的测试项目设置,其中有多个 suiteXmlFile。 pom 如下所示: 4.0.0 testautomation testautomation 0.0.1-SNAPSHOT
我正在使用 Maven 故障安全插件与 cobertura 插件一起执行集成测试用例。在故障安全插件的配置中,我给出了 suiteXmlFile ,它包含所有集成测试但是,当运行以下命令时,我收到错误
我是一名优秀的程序员,十分优秀!