Forum Discussion

corki's avatar
corki
Contributor
16 years ago

Unknown ERROR with RUNNING "Groovy Script" type testStep

Hello all,

      Can someone please explain me what is wrong with method :  testStep.run ( testRunner, context );
That "run" method makes me trouble all f.. day. I wrote it foolowing way and ALWAYS brings me ONE ERROR, but the code works and the groovy step has been executed properly. Everythings has gone find, but still that error appears :

---------------------------------------
Error: 

14:18:55,328 ERROR [SoapUI] An error occured [java.lang.NullPointerException], see error log for details
java.lang.NullPointerException

at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:156)
at FirstClass.main(FirstClass.java:129)


----------------------------------------------------------

My Code :


        WsdlProject        project  = new WsdlProject( "C:/......./soapui-project.xml", "" );

        WsdlTestSuite      testSuite = project.getTestSuiteByName("1 - Get_Categories");
        WsdlTestCase      testCase  = testSuite.getTestCaseByName("1.1.1 - GetCategories_All");
        WsdlTestStep      testStep  = testCase.getTestStepByName("GetCategories_All");
        WsdlTestRunContext context  = new WsdlTestRunContext( testStep );



        for(int i=0; i
if(testCase.getTestStepAt(i).getModelItem().toString().indexOf("WsdlGroovyScriptTestStep") >= 0 ) {
       
System.out.println("Found a Groovy Script before this step.");
// run this groovy script
WsdlTestRunContext i_context = new WsdlTestRunContext( testCase.getTestStepAt(i) );
testCase.getTestStepAt(i).run(i_context.getTestRunner(), i_context);
                }
        }
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Stanislav,


    What I can notice is that the way your instantiating your context does not give that context any knowledge of the runner (therefore i_context.getTestRunner()=null and because of that you get NullPointerException).
    For a hint how WsdlTestCaseRunner can be instantiated look at the source code of WsdlLoadTestRunner#InternalTestCaseRunner#run() method:

    runner = new WsdlTestCaseRunner( testCase, new StringToObjectMap() );

    and since your test case is known (hard-coded even) you should be able to all the test steps until the last one.

    I hope this hint will move you in the right direction. Let us know how it went.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla