[SoapUI] 从上一个测试步骤获取ID list,通过Groovy脚本动态生成 Data Source 供后面的步骤使用
https://support.smartbear.com/readyapi/docs/testing/data-driven/types/groovy.html
从官网拷贝code到SoapUI里面,result那里一直报错,仔细看发现result的颜色不对,正常应该是黑色,显示却是紫色。
后来猜想是不是result前面有隐藏的什么黑暗字符,果断抹一遍,发现还真是,抹干净就运行成功了。
// Import required class
import groovy.io.FileType
// Get current row
def row = testRunner.testCase.testSteps["DataSource"].currentRow;
// Get the home user directory
def directoryName = System.getProperty("user.home");
// Declare an array that will contain file names
def fileNames = [];
// Get a list of files in the directory
new File(directoryName).eachFile(FileType.FILES)
{
// Add the name of the file to the list
file -> fileNames.add(file.name);
}
// Check that the current row number does not exceed the array size
if (row < fileNames.size) {
// Return the name to data source's "File" property
result["File"] = fileNames[row];
}
浙公网安备 33010602011771号