我正在尝试使用groovy脚本步骤在soap UI中编写类并执行我需要的任何地方 但它显示错误:
" org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: 没有方法签名:excel.main()适用于参数类型: ([Ljava.lang.String;)values:[[]]可能的解决方案:wait(), wait(long),find(),any(),wait(long,int),find(groovy.lang.Closure)
import groovy.json.JsonSlurper
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.*;
import java.util.Iterator;
class excel {
static void ReadWriteExcel(String a,int b)
{
def projectPath = new
com.eviware.soapui.support.GroovyUtils(context).projectPath
//gets the path of the project root
FileInputStream fIpStream= new
FileInputStream(projectPath+"\\Bat_File_Data.xls")
HSSFWorkbook wb = new HSSFWorkbook(fIpStream);
HSSFSheet worksheet = wb.getSheetAt(0);
int noOfRows = worksheet.getLastRowNum();
int noOfColumns = worksheet.getRow(0).getLastCellNum();
for (int i=1;i<2;i++)
{
//def res = wb.getSheetAt(0).getRow(1).getCell(0);
def res = wb.getSheetAt(0).getRow(i).getCell(1);
//log.info res
Row row = worksheet.createRow(i);
Cell cell = row.createCell(2);
Cell cell1 = row.createCell(3);
cell.setCellValue(a);
cell1.setCellValue(b);
}
fIpStream.close(); //Close the InputStream
FileOutputStream output_file =new FileOutputStream(new
File(projectPath+"\\Bat_File_Data.xls"));
wb.write(output_file);
output_file.close();
}
}
class Groovy
{
static void main(String[] args)
{
ReadWriteExcel("Pass",2234);
}
}
答案 0 :(得分:2)
"matrix.h"
答案 1 :(得分:1)
在Soapui,没有编译任何东西,你可以使用这样的类:
class A{
def log
def context
def testRunner
def A(logIn,contextIn,testRunnerIn){
this.log = logIn
this.context = contextIn
this.testRunner = testRunnerIn
}
def method(){
//your code
}
//log, context, testRunner are global variables in Soapui
context.setProperty( "A", new A( log, context, testRunner) )
然后,使用context.A.method()
如果你在另一个测试步骤中,你可以使用:
context.workspace.getProjectByName("ProjectName").getTestSuiteByName("TESTSUITE").testCases["TESTCASE"].testSteps["TESTSTEP"].run(testRunner, context)
context.A.method()
在你的常规步骤之外运行你的课程