在soapUI中,如何将多个属性值从groovy脚本传输到包含属性的属性列表?

时间:2012-12-12 21:48:48

标签: groovy soapui

我正熟悉groovy(对于soapUI),并试图找出如何将一些属性值转移到属性列表的路障。试过财产转移步骤,但没有帮助。我有点想通知我需要使用'setPropertyValue''context.expand'来开始。只是无法连接点。

def myTestCase = context.testCase

File tempFile_first = new File("C:/Users/ethomas1/Desktop/my_Input_File_first.txt"
List lines_first = tempFile_first.readLines()

File tempFile_second = new File("C:/Users/ethomas1/Desktop/my_Input_File_Second.txt")
List lines_second = tempFile_second.readLines()

def x = Math.random()*10       // multiplying random with 10 so the resulting value would be <= 10.
i = String.valueOf(x).getAt(0)
i = i.toInteger()

myTestCase.setPropertyValue("num1", lines_first[i])
myTestCase.setPropertyValue("num3", lines_first[i])
myTestCase.setPropertyValue("num2", lines_second[i])
myTestCase.setPropertyValue("num4", lines_second[i])

num1 = context.expand( '${#TestCase#num1}' )
num2 = context.expand( '${#TestCase#num2}' )
num3 = context.expand( '${#TestCase#num3}' )
num4 = context.expand( '${#TestCase#num4}' )

log.info ("num1 is " + num1 + ", num2 is " + num2 + ", num3 is " + num3 + ", num4 is " + num4)

1 个答案:

答案 0 :(得分:0)

您可以使用.properties文件在任何级别将所有属性拉到一起,否则您必须在上面编写时编写groovy。 testRunner.testCase.testSuite.setPropertyValue( “PROPNAME”, “值”);