Escolar Documentos
Profissional Documentos
Cultura Documentos
def testIterationCountQry = "Some Query " def testIterationCount,TC_Status,TC_StatusExp,RemarkExp, Remark def respReturnCode // DB connection try{
String jdbcURL=testRunner.testCase.testSuite.project.getPropertyValue('jdbcURL')
com.eviware.soapui.support.GroovyUtils.registerJdbcDriver(dbDriverName)
sqlConnection.eachRow(testIterationCountQry){row->
testIterationCount=row[0] }
//################### Before SOAP call Test datas ############################################### def testTestDataQry = "Some Query " List testDataBefore = new ArrayList() sqlConnection.eachRow(testTestDataQry){row ->
testDataBefore.add(row.FirstColumn) testDataBefore.add(row.SecondColumn) } //################### Invoke the SOAP call here ################################################# respReturnCode = invokeSoapCall()
if(testIterationCount>0){
value1= testDataBefore[i]
log.info value1
valueBeforeNotificationStatus=testDataBefore[j] log.info valueBeforeNotificationStatus def retriveNotiStatusAfter = "select ColumnName from TableName where id='"+valueOfID+"'" def valueAfterNotificationStatus
sqlConnection.eachRow(retriveNotiStatusAfter){ rownew->
if (valueAfterNotificationStatus=='Y'){
///TC_Status="Pass"
i=j+1 j=i+1
testIterationCount-} } else{ TC_Status="Fail" Remark= "No test data / Pre-condition mismatch!" testRunner.fail("No Test data in Database") log.info Remark } } else {
} catch(SQLException e) { e.printStackTrace() TC_StatusExp="Failure" RemarkExp = "Exception occurred on DB Connection or query Execution" testRunner.fail("Database exception") } catch(Exception error) { error.printStackTrace() TC_StatusExp="Failure" if(testIterationCount == 0) {
RemarkExp = "No test data / Pre-condition mismatch!" testRunner.fail("No Test data in Database")
/*Test Result*/ def project = testRunner.testCase.testSuite.project; def testSuiteName = testRunner.testCase.testSuite.name def testCaseName = testRunner.testCase.name def testCase = project.testSuites[testSuiteName].testCases[testCaseName];
def target = "C:\\AutomationReport\\"+testSuiteName+".html" File wf = new File(target) def projectPath = "C:\\" def reportsPath = projectPath+"\\AutomationReport" new File(reportsPath).mkdir() def fileName_temp = reportsPath+"\\"+testSuiteName+".html" def writeToFile1
else { //Create html page with title only log.info('Test case report') writeToFile1 = new FileWriter(fileName_temp,false) //def writeToFile = new eFileWriter(fileName_temp,false) writeToFile1.write("<table border=1 width='90%' align='center' cellpadding=0 cellspacing=2 BGCOLOR=#C0C0C0 >") writeToFile1.write(" <tr bgcolor='#00BFFF' style='color:black;text-align:center;fontsize:20'><th>TestCaseName</th>" + "<th>Input</th><th>Output</th> <th> Result </th> <th> Remark </th>")
} if(TC_StatusExp=="Failure"){ writeToFile1.write("<tr bgcolor='white' style='text-align:center;'>" +"<td>"+ testCaseName + "</td><td>" + "No input tag for the request" +"</td><td>"+"returnCode: "+respReturnCode + " </td><td>"+TC_StatusExp+" </td><td>"+RemarkExp+"</td>") } else{ writeToFile1.write("<tr bgcolor='white' style='text-align:center;'>" +"<td>"+ testCaseName + "</td><td>" + "No input tag for the request" +"</td><td>"+"returnCode: "+respReturnCode + " </td><td>"+TC_Status+" </td><td>"+Remark+"</td>") }
writeToFile1.close() //Update pass or fail count in main html page if (TC_Status == "Pass") { passcount = context.expand('${#Global#Pass}') passcount = passcount.toInteger() + 1 passcount = passcount.toString() com.eviware.soapui.SoapUI.globalProperties.setPropertyValue('Pass',passcount)} else { failcount= context.expand('${#Global#Fail}') failcount = failcount.toInteger() + 1 failcount = failcount.toString() com.eviware.soapui.SoapUI.globalProperties.setPropertyValue('Fail',failcount)}
//################################ Holder Starts ######################################### //Method invoking soap request public String invokeSoapCall(){
def project = testRunner.testCase.testSuite.project def testSuiteName= testRunner.testCase.testSuite.name def testCaseName= testRunner.testCase.name def testCase= project.testSuites[testSuiteName].testCases[testCaseName] def testStepName= testCase.getTestStepAt(0).name def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) holder = groovyUtils.getXmlHolder(testStepName+"#request" )
def testStep = testCase.getTestStepAt(0); /*Run the soapui*/ testRunner = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner(testCase, null); testStepContext = new com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext(testStep); testStep.run(testRunner, testStepContext);
/*reading the response*/ def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils( context ) holder1 = groovyUtils1.getXmlHolder( testStepName+"#response" ) def value = holder1.getNodeValue("//returnCode") log.info("Response is :" + value); return value } //################## Holdder Ends #############################################################