Creating script library in SoapUI free version
<p>I am new in SoapUI and groovy scripting</p>
<p>I would like to create a repository of groovy scripts that can be reused at various test steps</p>
<p>I am using SoapUI Free version and following is the structure of my SoapUI Project</p>
<pre><code>Project
|-TestSuite
| |-TestCase
|   |-TestSteps
|     |-LocalScript (Groovy TestStep to reuse library scripts)
|     |-OtherTestStep (Run TestCase TestStep)
|-ScriptLibrary
  |-TestCase
    |-TestSteps
      |-GroovyScriptStep1 (Contain a class for commonly used functions)
      |-GroovyScriptStep2 (Contain another class for other functions)
</code></pre>
<p>Here is what I was able to do:</p>
<p>I was able to create a library using the sample mentioned in <a href="http://www.doan.me/script-library-in-soapui-free.aspx" rel="noreferrer">this post</a>. Similar to example in the post, my code in test step (GroovyScriptStep1 as per above structure) of library was just reading some value from external file and is used in test step of other TestSuite (LocalScript step in above structure).</p>
<p>Here is the problem:</p>
<p>Now I want to create a new class and add a function to it which will need info from running class and simply print it. The difference here is that some values are generated in the test run and should be passed to library script inorder to process/print etc.</p>
<p>To make my question more clear following is the code snippet</p>
<p>I will be using a simple scenario here</p>
<p>Sample objective: Want to be able to print all the assertions and status (since this will be used in all the test cases I want to create a library)</p>
<p>Code for same when not using library will be as under(this can go as groovy script step)</p>
<pre><code>def obj = context.testCase.getTestStepByName(&quot;Request 1&quot;);
def assertions = obj.getAssertionList()

//Loop on assertions
assertions.each{
    log.info(it.name +  ' --&gt; ' + it.status)
</code></pre>
<p>Code something similar in Library TestSuite's Test case step</p>
<pre><code>context.setProperty(&quot;Assertions&quot;, new Assertions());

class Assertions{
    
    def printAssertion(def someArgumentToGetAssertionlistforTestStepinAnotherTestSuite){
        
        
        def obj = ????
        
        def assertions = obj.getAssertionList()
        
        //Loop on assertions
        assertions.each{
            log.info(it.name +  ' --&gt; ' + it.status)
        }
    }
        
}
</code></pre>
<p>Code from where I want to call this method (LocalScript as per above project structure)</p>
<pre><code>scripts = testRunner.testCase.testSuite.project.testSuites[&quot;ScriptLibrary&quot;]; 
scripts.testCases[&quot;Scripts&quot;].testSteps[&quot;Assertions&quot;].run(testRunner, context);

context.Assertions.printAssertion(ArgumentRequired);
</code></pre>
<p>This is just one example, I want to create libraries of some more common scripts that use context variable when used locally</p>
<p>Kindly help me with this and please let me know if some more information/clarification is required</p>