Forum Discussion

Apoorva6's avatar
Apoorva6
Frequent Contributor
9 years ago
Solved

How to append results of different Test cases to one external file ?

Hi , I need help for daily sanity. Here is the story.

 

What is sanity ?

To check connectivity B/w App A, B and C. in IST, JST and UAT Environments

ModifyCustomer: From B to C , it changes customer name  (Here I change customer name to current date and set changed name to SearchCustomer Request)
SearchCustomer: From A to B to C (it searches the customer name after ModifyCustomer)

What I am doing: In all Environment I have sample Customer account with Customer name and in each Environment I will modify customer name daily to current date and try to retrive same
If both ModifyCustomer and SearchCustomer passes, then I will write same to file. At present with below script in SearchCustomer script assertion, I am able to achieve sanity for one Environment only. I need a way to append the same for all environment in single file.
I have 3 same Test case for different Environments.

 

Here is the sample script under Script assertion of SearchCustomer in JST Test case. Similarly I have UAT and IST Test case

 

===========================

import javax.mail.*
import java.text.SimpleDateFormat
try{
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder("Search_Customer#Response")
def holder1 = groovyUtils.getXmlHolder("ModifyCustomer#Request")
def frm_SearchCustomer_res= holder.getNodeValue("//*:customerName")
def frm_modifyCust_req = holder1.getNodeValue("//*:CustName")


def DT = new Date()
trnID = new SimpleDateFormat("ddMMyyyy")
def daytime = trnID.format(DT)
def sub

//def FileRes1 = new File("C:\\SoapProj\\"+daytime+".txt")
if (frm_SearchCustomer_res == frm_modifyCust_req)

{
log.info ("JST_PASSED")
        sub = "Sanity Passed"
        log.info("Passed")
        def FileRes =  new File("C:\\SoapProj\\"+daytime+".txt")
        if (FileRes.exists() ) {
            FileRes.append("JST_PASSED") }
        

      
}
else
{
        sub = "Sanity FAILED port"
        log.info("Failed")
    def FileRes1 = new File("C:\\SoapProj\\"+daytime+".txt")
        
        FileRes1.write("JST_FAILED")
        
}

}
catch (Exception e)
{

log.info ("Script failed")

}

============================

  • If you run the tests using Launch Test runner by right click on the test suite and use html reports then you do not have to do any, the report gets generated for the all the tests you do. That is done by out-of-the-box. Can you try this if not already? I believe that you do not really need custom script unless you do not satisfy with Junity style html reports.

     

    Please see follow the link.

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    If you run the tests using Launch Test runner by right click on the test suite and use html reports then you do not have to do any, the report gets generated for the all the tests you do. That is done by out-of-the-box. Can you try this if not already? I believe that you do not really need custom script unless you do not satisfy with Junity style html reports.

     

    Please see follow the link.

    • Apoorva6's avatar
      Apoorva6
      Frequent Contributor

      The link you provided say its for SoapUI Pro, but I am using free version.

      Regarding Test runner, how can I run that via command line ? Also, in script I am using filename with currentdate name so only the result of last test case is written as of now, By running test runner , can the result of assertion of all test case (passed and failed) be created in seperate path ? because I need the result file to be mailed later on daily basis.

      • nmrao's avatar
        nmrao
        Champion Level 3
        Did you try it? or just saying ?