1
以下testng.xml
文件有三個參數。我不希望參數customerCode
被硬編碼。我想通過改變/ diffent customerCode
以下testng.xml
文件,但我也想有彼得作爲默認customerCode
如果萬一我不通過mvn
命令行提供一個如下:如何通過mvn命令行傳遞testng.xml參數值
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>