【发布时间】:2017-09-11 23:58:34
【问题描述】:
testng.xml 文件下面有三个参数。我不希望参数customerCode 被硬编码。我想将不同/不同的customerCode 传递给以下testng.xml 文件,但我也想将Peter 作为默认customerCode,以防万一我不通过mvn 命令行提供一个,如下所示:
mvn test -DcustomerCode=customer1 -Ptestng.xml
下面是testng.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestSuite" parallel="false">
<test name="someTest">
<parameter name="browserType" value="chrome_win"></parameter>
<parameter name="Url" value="http://regression.mytest.com/?customerCode=" />
<parameter name="customerCode" value="Peter"/>
<groups>
<run>
<exclude name="navigateToHomePage" />
</run>
</groups>
<classes>
<class name="com.automation.customermanagement.createTest.myIntegrationTest" >
<methods>
<exclude name="deleteCustomer" />
</methods>
</class>
</classes>
</test>
</suite>
我如何做到这一点?有没有办法做到这一点?
以下是我的 POM 文件。我应该将customerCode 属性放在配置文件中的什么位置?
<profile>
<id>AddMgmtTest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>admgmttestng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
【问题讨论】:
标签: java xml maven selenium-webdriver