Forum Discussion

Praveen_Dsouza's avatar
Praveen_Dsouza
Occasional Contributor
16 years ago

Creating an HTML file in Groovy Script

Hi,
I want to add the "Success" or "Failure" message for each operation (Test Case) in a HTML file. I am trying to create this in a Groovy Script.
I am already creating the txt files in the Groovy Script which will contain the Request & Response.
Please let me know me how to create the HTML file with "Success" or "Failure" messages contained within for each test case. Please respond. Any response will be appreciated (even a question to understand it better).
Thanks, Praveen.

5 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    I think you should be able to do what you need using Groovy templates. This link should get you started.

    Good luck!

    Regards,
    Dain
  • Praveen_Dsouza's avatar
    Praveen_Dsouza
    Occasional Contributor
    Thanks so much for the response. I know how to create a simple HTML file in Groovy Script. The only thing I want to know is how to get the "success" or "failure" message which is the result of the operations or TestCases. I tried response.getStatusCode() but this does not perform the necessary task. May be I need to fetch the assertion value but I don't know how to do that. Below code shows the file generation code; where 'bw' is "BufferedWriter" object. Please reply..

    bw.write("-------------------STATUS CODE---------------------");
    bw.newLine();
    bw.newLine();
            bw.write("");
    bw.write(httpResponse.getStatusCode());
          bw.write("");
    bw.newLine();
    bw.newLine();
    bw.write("-------------------STATUS CODE---------------------");
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    try using

    testRunner.status

    to get the status of the entire testcase.

    If you want the status of an individiual teststep, have a look at http://www.eviware.com/blogs/oleblog/?p=442, the mentioned TestStepResult has a correponding status property that you could use.

    regards!

    /Ole
    eviware.com
  • Praveen_Dsouza's avatar
    Praveen_Dsouza
    Occasional Contributor
    Thanks for the response. I have 18 WebService operations (TestCases). I have 18 Groovy Scripts. I run these test cases through the PustToTest. I am trying to create 1 HTML report which will contain "Success" and "Failure" messages as shown in the screen shot (from Pro Version). I am using free version Soap UI 2.5.1
    Please let me know if there is an easy way of creating such an HTML along with the SUCCESS & FAILURE messages for each test case. Please provide a code snippet to arrive at SUCCESS or FAILURE using "testRunner.status" or "def results = testRunner.results"
    Please excuse me if I seem ignorant, I am new to Soap UI.