Я ответил на все вопросы по 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>
Заключение. 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>
дым. 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>
регрессия. 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>
пом. 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>
Мне нужно выполнить инициализацию. xml затем либо дым. xml или регрессия. xml затем заключение. xml в последовательном порядке. Рассмотрим следующий набор в качестве примера:
<suiteXmlFiles>
<suiteXmlFile>Initialize.xml</suiteXmlFile>
<suiteXmlFile>smoke.xml</suiteXmlFile>
<!-- or -->
<!-- <suiteXmlFile>regression.xml</suiteXmlFile> -->
<suiteXmlFile>Conclude.xml</suiteXmlFile>
</suiteXmlFiles>
Как я могу параметризовать средний suiteXmlFile из pom? Я попытался использовать команду ниже, но она не работает и вызывает исключение.
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
Если я использую команду ниже, она работает, но не выполняет инициализацию. xml и завершение. 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>
Пожалуйста, помогите. Также приветствуются любые ссылки или полезные ссылки.