Forum Discussion
divman
11 years agoContributor
Here is my groovy. I have Workspace which has two projects "Holds Inquiry" and "Library". I am having all my reusable common codes in my Library project. When i run my "Holds Inquiry", in the Setup Script, i have a below code which i will get the testdata from excel as datasource (though Pro version has datasource option, i need to do more other stuff, so i am using Groovy) and do my other stuff.
import org.apache.poi.hssf.usermodel.*;
dFormatter = new HSSFDataFormatter()
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def projectPath = groovyUtils.projectPath
def fileName = "Holds_Inquiry__TestData.xls"
srcBook = new HSSFWorkbook(new FileInputStream(new File(projectPath + "\\" + fileName)))
fEval = new HSSFFormulaEvaluator(srcBook)
sourceSheet = srcBook.getSheetAt(0)
context.rowCounter = 1
library = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Library")
suitename = library.getTestSuiteByName("Driver_Scripts");
module1 = suitename.testCases["Methods"].testSteps["Initialize_DataSetup"]
module1.run(testRunner, context)
def dataverifySheet
def startTestData = context.InitializeTestData
startTestData.FirstData(sourceSheet, dataverifySheet, dFormatter, fEval, projectPath)
context.srcWkSheet = sourceSheet
context.projPath = projectPath
my above code will be calling an another Project named "Library", which is having a test case "Methods", which has a step "Initialize_DataSetup", which has a reusable code (here to get the testdata from sxcel as source..). This is my setup.
I am getting error when i run through TestRunner. Could you please help me on this? Because we have all our regression suites with this structure (developed before converting to SoapUI Pro).
import org.apache.poi.hssf.usermodel.*;
dFormatter = new HSSFDataFormatter()
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def projectPath = groovyUtils.projectPath
def fileName = "Holds_Inquiry__TestData.xls"
srcBook = new HSSFWorkbook(new FileInputStream(new File(projectPath + "\\" + fileName)))
fEval = new HSSFFormulaEvaluator(srcBook)
sourceSheet = srcBook.getSheetAt(0)
context.rowCounter = 1
library = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Library")
suitename = library.getTestSuiteByName("Driver_Scripts");
module1 = suitename.testCases["Methods"].testSteps["Initialize_DataSetup"]
module1.run(testRunner, context)
def dataverifySheet
def startTestData = context.InitializeTestData
startTestData.FirstData(sourceSheet, dataverifySheet, dFormatter, fEval, projectPath)
context.srcWkSheet = sourceSheet
context.projPath = projectPath
my above code will be calling an another Project named "Library", which is having a test case "Methods", which has a step "Initialize_DataSetup", which has a reusable code (here to get the testdata from sxcel as source..). This is my setup.
I am getting error when i run through TestRunner. Could you please help me on this? Because we have all our regression suites with this structure (developed before converting to SoapUI Pro).
Related Content
- 11 years agomike_lyons