groovy - Loop test steps in multiple test cases using SOAPUI -


i'm having issue in automating web services.

actually have excel sheet containing input , outputs needed.

i wrote groovy script retrieve inputs, save them in properties, execute query, retrieve outputs , compare them excel outputs.

my problem process execute 1 test case.

i want "pimp" process every line of excel sheet dealt test case.

here's groovy code :

import jxl.* import jxl.write.*  workbook workbook1 = workbook.getworkbook(new file("c:\\users\\****\\desktop\\groovypssheet.xls")) sheet sheet1 = workbook1.getsheet(0)  (int i=6; i<sheet1.getrows(); i++)     {         sleep 1000         if (sheet1.getcell(0,i).getcontents()=="")         {             i++         }         cell clairance = sheet1.getcell(3,i)         cell etatpatho = sheet1.getcell(2,i)         cell idlreq = sheet1.getcell(1,i)         cell idprod = sheet1.getcell(0,i)         cell typeprod = sheet1.getcell(4,i)         testrunner.testcase.setpropertyvalue( "clairance", clairance.getcontents() )         testrunner.testcase.setpropertyvalue( "etatpatho", etatpatho.getcontents() )         testrunner.testcase.setpropertyvalue( "idlreq", idlreq.getcontents() )         testrunner.testcase.setpropertyvalue( "idprod", idprod.getcontents() )         testrunner.testcase.setpropertyvalue( "typeprod", typeprod.getcontents() )         sleep 500         def executequery = testrunner.testcase.teststeps['executequery']         executequery.run( testrunner, context )         sleep 1000         groovyutils = new com.eviware.soapui.support.groovyutils(context )         holder = groovyutils.getxmlholder ("executequery#response")          id_type_alerte = holder.getnodevalue("//id_type_alerte")         testrunner.testcase.setpropertyvalue( "id_type_alerte", sheet1.getcell(5,i).getcontents() )          idproduit = holder.getnodevalue("//idproduit")         testrunner.testcase.setpropertyvalue( "idproduit", sheet1.getcell(6,i).getcontents() )           typeproduit = holder.getnodevalue("//typeproduit")         testrunner.testcase.setpropertyvalue( "typeproduit", sheet1.getcell(7,i).getcontents() )          id_ter_per = holder.getnodevalue("//id_ter_per")         testrunner.testcase.setpropertyvalue( "id_ter_per", sheet1.getcell(8,i).getcontents() )          lib_ter_per = holder.getnodevalue("//lib_ter_per")         testrunner.testcase.setpropertyvalue( "lib_ter_per", sheet1.getcell(9,i).getcontents() )          id_ter_com = holder.getnodevalue("//id_ter_com")         testrunner.testcase.setpropertyvalue( "id_ter_com",sheet1.getcell(10,i).getcontents() )          id_typ_ter = holder.getnodevalue("//id_typ_ter")         testrunner.testcase.setpropertyvalue( "id_typ_ter", sheet1.getcell(11,i).getcontents() )          lib_ter = holder.getnodevalue("//lib_ter")         testrunner.testcase.setpropertyvalue( "lib_ter", sheet1.getcell(12,i).getcontents() )          id_nature_ci = holder.getnodevalue("//id_nature_ci")         testrunner.testcase.setpropertyvalue( "id_nature_ci", sheet1.getcell(13,i).getcontents() )          id_ter = holder.getnodevalue("//id_ter")         testrunner.testcase.setpropertyvalue( "id_ter", sheet1.getcell(14,i).getcontents() )          id_sequence_ter = holder.getnodevalue("//id_sequence_ter")         testrunner.testcase.setpropertyvalue( "id_sequence_ter", sheet1.getcell(15,i).getcontents() )          id_fic_ci = holder.getnodevalue("//id_fic_ci")         testrunner.testcase.setpropertyvalue( "id_fic_ci", sheet1.getcell(16,i).getcontents() )         sleep 1000      }   workbook1.close() 

thanks !

seems want next testcase current testsuite each row in datasheet instead of performing operation in current testcase each time. i'm not sure goal, can collect testcases current testsuite , select next 1 each row, can trick:

// testcases current testsuite list def alltestcases = testrunner.testcase.testsuite.testcases.collect{ name, testcase ->     return testcase }  // row iteration (int i=6; i<sheet1.getrows(); i++) {      // testcase      def testcase = alltestcases.take(1);      // drop element list change next iteration      alltestcases = alltestcases.drop(1);      ...      ...      // in rest of code use testcase variable list      // instead of using testrunner.testcase take current 1      testcase.setpropertyvalue("clairance", clairance.getcontents())      testcase.setpropertyvalue("etatpatho", etatpatho.getcontents())      ...      def executequery = testcase.teststeps['executequery']      executequery.run( testrunner, context )      ... } 

hope helps,


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -