3

我正在熟悉 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)
4

1 回答 1

0

您可以使用 .properties 文件在任何级别将所有属性拉到一起,否则您必须像上面写的那样编写 groovy。testRunner.testCase.testSuite.setPropertyValue("PropName","Value");

于 2012-12-17T07:23:12.590 回答