Forum Discussion

PhilUI's avatar
PhilUI
New Contributor
15 years ago

Logging

Hello,
i'm using a script to generate a logfile containing some information about my tests.
The script runs as TearDown script of the test suite.
I'm able to get the information about the testCases and testSteps in the suite.
But the testSteps in the suite are nothing else as testCases of another suite.
Is there a possibility to get also the information about these steps e.g. the status?

FYI
TestSuite: B
TestCase 1
TestStep1 --> This runs a testCase of TestSuite A.

Yes i have to do it like this and no i can't change the structure of my project.

Thx in advance
PhilUI

7 Replies

  • PhilUI's avatar
    PhilUI
    New Contributor
    More precisely i want something like the TestSuit Log in a .text file
    (I'm not using soapUI pro)

    Thx
    PhilUI
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    Phil,

    Easiest way to get logs in a text file is using Java PrintWriter. To get the overall PASS/FAIL status of called test step however you can use the "status" method depending upon how you are making a call to the test step of different test suite. If you would have been calling a test step within the same test case itself, it would have been something like below:

    def validation = testRunner.runTestStepByName("test_step_name") ;
    log.info "Validation Status = $validation.status"

    However if you are calling test case in suite A like below:

    result = tc.run( null,false); // where tc is test case of test suite A

    then "result" basicially is an object of class "WsdlTestCaseRunner" and you might be able to call :

    result.getStatus()

    to get the status of the test case.

    If you have log.info all over the test case (groovy script) which you want in a separate file, you will have to play around with soapui-log4j.xml file placed in the bin folder of soapui installation directory. You can update that to output all your log.info in a file you specified in soapui-log4j.xml. Let me know if you need more help on this.

    Regards,
    Deepesh Jain
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    In that case, you need to update the soapui-log4j.xml file located under bin folder of your soapui installation directory. Open the soapui-log4j.xml file and include the following code before the section for loggers:

       <appender name="GroovyFile" class="org.apache.log4j.FileAppender">
    <errorHandler class="org.apache.log4j.helpers.OnlyOnceErrorHandler"/>
    <param name="File" value="C:\\YOUR_FILE.TXT"/>
    <param name="Threshold" value="DEBUG"/>
    <param name="Append" value="false"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n"/>
    </layout>
    </appender>


    Now under logger section, include the following:

    <logger name="groovy.log">
    <appender-ref ref="GroovyFile"/>
    </logger>


    The first portion of the code creates an option of logging everything to a file of your choice and the second portion of the code logs all your logs from groovy script to this file. If you need to log everything at all groovy and non groovy to your file, you don't need the second potion of the code. Instead just update the root logger like below:


    <root>
    <priority value="INFO" />
    <appender-ref ref="GroovyFile"/>
    </root>


    Hope this helps.

    Regards,
    Deepesh Jain
  • PhilUI's avatar
    PhilUI
    New Contributor
    Hello deepesh jain,

    first thx for your help so far.
    I've tried to edit the soapui-log4j.xml but nothing happend.

    result = tc.run( null,false); // where tc is test case of test suite A
    That doesnt solve my problem because i'm already able to get the results of my TestCase but I'm not able to get the status of the corresponding TestSteps.
    I tinnk the Problem maybe is, that the TestCase in the suite runs a "Target TestCase" taht conatins the TestSteps.

    So waht i need i s.th. like this

    TestCase [Create archives] started at 2011-11-09 09:37:55.125
    Step 1 [Create Archives] OK: took 10371 ms
    -> Script-result: java.lang.ProcessImpl@df8f29
    Step 2 [Get Server Status - A] OK: took 2234 ms
    -> Retrieve server status - OK - 1648
    Step 3 [Get Server Status - B] OK: took 767 ms
    -> Retrieve server status - OK - 13
    TestCase [Create archives] finished with status [FINISHED], time taken = 13372
    TestCase [Insert & Retrieve] started at 2011-11-09 09:38:08.540
    Step 1 [Insert & Retrieve (simple document) - A] OK: took 840 ms
    -> Generate new document - OK - 137
    -> Insert document - OK - 124
    -> Transfer recordId - OK - 2
    -> - Performed transfer [recordId]
    -> Retrieve document - OK - 10
    Step 2 [Insert & Retrieve (simple document) - B] OK: took 406 ms
    -> Generate new document - OK - 5
    -> Insert document - OK - 96
    -> Transfer recordId - OK - 1
    -> - Performed transfer [recordId]
    -> Retrieve document - OK - 9
    TestCase [Insert & Retrieve] finished with status [FINISHED], time taken = 14702
    TestCase [Search(Volltext)] failed [Cancelling due to failed test step], time taken = 3240

    This is the TestSuite Log which soapUI automatically generates in the logwindow

    I hope you can help me out

    thx in advance

    phil
  • PhilUI's avatar
    PhilUI
    New Contributor
    Year, now everything is logged in my file, but thats a little bit to much ^^
    Is there any possibilty to log only the output of the testSuit log?

    regards

    phil
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    Hi Phil,

    If you are getting everything in the log file that's because the logging level in soapui log 4j is set to root level. You will have to play around with what other options you can choose that with. I haven't tried my hands extensively on this so I won't be able to help you much in this regards. Sorry about that.

    Regards,
    Deepesh Jain