1
设置中同时有两个属性值我想测试中的GetWeather web服务如何使用Groovy从文本文件
http://www.webservicex.com/globalweather.asmx
我有这个内容的文本文件: 蒙特利尔 加拿大 卡尔加里 加拿大
我的要求是:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="http://www.webserviceX.NET">
<soap:Header/>
<soap:Body>
<web:GetWeather>
<!--Optional:-->
<web:CityName>${#Project#City}</web:CityName>
<!--Optional:-->
<web:CountryName>${#Project#Country}</web:CountryName>
</web:GetWeather>
</soap:Body>
</soap:Envelope>
我Groovy代码是:
def f = new File("c:\\temp\\Data.txt")
def fr= new FileReader(f)
def br = new BufferedReader(fr)
def s = br.readLine()
def x = br.readLine()
while(s && x !=null)
{
testRunner.testCase.setPropertyValue("City",s)
testRunner.testCase.setPropertyValue("Country",x)
testRunner.runTestStepByName("GetWeather - Request 1")
s = br.readLine()
x = br.readLine()
}
但我没有读取文件。 请任何帮助,谢谢
谢谢你,它正在阅读txt文件,但如何阅读每一行,因为我有不同的城市和国家名称的多行。 – parisFoxparis
不幸的是,我不明白你在问什么。我在我的答案中添加了一个解释。也许它会回答你的问题。 –
现在我明白了,谢谢你的解释。这个对我有用 – parisFoxparis