Rest soapui或soapui pro中的DataGen?

Rest soapui或soapui pro中的DataGen?,rest,testing,soapui,data-generation,Rest,Testing,Soapui,Data Generation,我想在SoapUI中测试RESTfulWeb服务。为此,我需要从Excel中读取值并将其传递给请求 我在网上搜索,我发现这是可能的通过。我有SoapUI,但我找不到那个选项 有人能告诉我DataGen TestStep是否在SoapUI-4.5.1或SoapUI Pro中可用。我99%确信数据源等仅在SoapUI Pro中可用。不过,在groovy脚本中也可以完成同样的任务,但与电子表格相比,从文本文件中读取可能会更好。因此,SoapUI设置脚本中有一个选项可以提前运行 您可以将Excel转换为

我想在SoapUI中测试RESTfulWeb服务。为此,我需要从Excel中读取值并将其传递给请求

我在网上搜索,我发现这是可能的通过。我有SoapUI,但我找不到那个选项


有人能告诉我DataGen TestStep是否在SoapUI-4.5.1或SoapUI Pro中可用。

我99%确信数据源等仅在SoapUI Pro中可用。不过,在groovy脚本中也可以完成同样的任务,但与电子表格相比,从文本文件中读取可能会更好。

因此,SoapUI设置脚本中有一个选项可以提前运行 您可以将Excel转换为csv或文本文件,并从中处理日期

我已经用REST服务做了一些测试,只使用从文本文件读取功能。 代码如下所示:

//Load the text file
 def inputFile = new File("C://Temp//whatever");

//Create an empty list...
 def mega_List = [];

//...and then populate it with the contents
 // of the text file.
 addSomeThingToList = {mega_List.add(it)};
 inputFile.eachLine(addSomeThingToList);

//...and assign its value to the Test Case Property
 def tc = testRunner.testCase;


//Randomly pick an item from the list...
def index = context.expand( '${#TestCase#index}' ).toInteger()


 if ( index <  mega_List.size() ) { 
def id = mega_List.get(index);
 index++
tc.setPropertyValue("id", id);
tc.setPropertyValue("index", index.toString());

 }
else {
tc.setPropertyValue("index", "0");
tc.setPropertyValue("id", "0");
testrunner.cancel( "time to go home" )
}
//加载文本文件
def inputFile=新文件(“C://Temp//whatever”);
//创建一个空列表。。。
def mega_列表=[];
//…然后用内容填充它
//文本文件的。
addSomeThingToList={mega_List.add(it)};
inputFile.eachLine(addSomeThingToList);
//…并将其值指定给测试用例属性
def tc=testRunner.testCase;
//从列表中随机选取一项。。。
def index=context.expand('${TestCase}}').toInteger()
如果(索引
该步骤仅在Soap UI Pro(Ready API)中可用

在SOAPUI的免费版本中,您可以使用POI方式通过groovy脚本读取excel文件,并在输入请求中传递这些值

import org.apache.poi.xssf.usermodel.*
import org.apache.poi.ss.usermodel.DataFormatter;

def fs = new FileInputStream("F:\\Gaurav\\soapui\\readFile.xlsx")
def wb = new XSSFWorkbook(fs)
def ws = wb.getSheet("Sheet1")
def r = ws.getPhysicalNumberOfRows()

for(def i =0 ; i < r ; i++)
{
def row = ws.getRow(i);
def c=row.getPhysicalNumberOfCells()

for(def j=0; j <c ; j++)
{
def cell= row.getCell(j)

// to convert everything to a String format
DataFormatter formatter = new DataFormatter()
def cellValue=formatter.formatCellValue(cell)

log.info cellValue

}
}
然后在您的请求中,您可以像下面那样展开它

${#TestCase#tcprop}

通过这种方式,您可以在SOAPUI免费版本4.5中实现相同的DataGen功能。SOAPUI不支持数据生成或数据源方法。您可以使用SOAPUI专业版
${#TestCase#tcprop}