fetch test case name by Groovy script

UK_UK_ Posts: 18

I had 2 questions :
1. How to fetch test response by groovy script.
2. How to get test case name by some runtime script using groovy

Comments

  • benken_parasoftbenken_parasoft Posts: 705 ✭✭✭
    edited November 2018

    How to fetch test response by groovy script

    You can chain an Extension Tool to the Response output of your test. Your script should contain a method with two arguments. The first argument to the method in your script will be the response message.

    How to get test case name by some runtime script using groovy

    The second argument to the method in your script is an object of type com.parasoft.api.ScriptingContext. You can call getContextName() on that ScriptingContext object to get the name of the tool running your script. If you need to get the name of the parent tool then you can call getParentContext() on the ScriptingContext object then call getContextName() on that parent context.

    Groovy Example:

    import com.parasoft.api.*
    
    void test(Object input, ScriptingContext context) {
        Application.showMessage(input.toString())
        Application.showMessage(context.getParentContext().getContextName())
    }
    

    Test name and execution detail, including test traffic, can also be saved after test execution has completed in a SOAtest XML report file. So, you can also consider running a script outside of SOAtest which parses the XML report to extract whatever specific information you desire about the test run.

Sign In or Register to comment.