Saturday, 23 April 2011

Bug: SoapUI fails to add REST Test Method to Test Case when using Resource solely to share parameters

[Duplicated from my EviWare/SoapUI forum post here.]

Using SoapUI 3.6.1, I ran into same problem as listed here viewtopic.php?f=2&t=4462&start=15 (which I named this topic after).
I downloaded the 3.6.2 nightly and retried. No fix.
OOI, by opening the project XML in Eclipse, I can see that despite throwing the same error, if I save, the new testStep does appear in the XML. I've tried "Resolve" (no errors), loading and reloading, restarting SoapUI. No help.
Below are more details of the problem some more and a workaround ...

The problem seems to happen when using resources to add parameters to methods.

Project structure explanation:
A set of methods M1 all take parameters x, y & z. Rather than creating x, y & z in every method in M1, create a resource R1 with parameters x, y & z and place all M1 methods under it. (they'll then automatically have parameters x, y & z).
Another set of methods M2 take all M1 parameters and also all take parameter w. Create resource R2 under R1 and place M2 under R2. (M2 methods will then automatically have parameters w, x, y & z).

The image shows this structure at the bottom where Resource "task-based" has 3 parameters that setUrl() (and its imminent siblings) all use). (In case you're curious, the API is RememberTheMilk.com, calls all share the same path and are distinguished by the "method" parameter.)

Workaround:
I recreated the troublesome method (setUrl in this case) outside my structure with all the parameters and retried adding to my testcase -- it worked fine.

Source:
I checked the source briefly when the problem happens...
Thu Apr 21 11:20:58 BST 2011:ERROR:java.lang.NullPointerException
   java.lang.NullPointerException
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.ensureUniqueName(WsdlTestCase.java:312)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.insertTestStep(WsdlTestCase.java:503)
    at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.insertTestStep(WsdlTestCase.java:494)
    at com.eviware.soapui.impl.wsdl.panels.testcase.WsdlTestCaseDesktopPanel$AddWsdlTestStepAction.run(WsdlTestCaseDesktopPanel.java:698)
 private boolean ensureUniqueName( WsdlTestStep testStep )
 {
  String name = testStep.getName();
It's the top of ensureUniqueName() suggesting the testStep argument is null.
 public WsdlTestStep insertTestStep( TestStepConfig stepConfig, int ix, boolean clearIds )
 {
  WsdlTestStep testStep = createTestStepFromConfig( newStepConfig );

  if( !ensureUniqueName( testStep ) )
So something went awry with createTestStepFromConfig().
 private WsdlTestStep createTestStepFromConfig( TestStepConfig tsc )
 {
  WsdlTestStepFactory factory = WsdlTestStepRegistry.getInstance().getFactory( tsc.getType() );
  if( factory != null )
  {
   WsdlTestStep testStep = factory.buildTestStep( this, tsc, forLoadTest );
   return testStep;
  }
  else
  {
   logger.error( "Failed to create test step for [" + tsc.getName() + "]" );
   return null;
  }
 }
Assuming logger.error() would show in SoapUI's "error log" or "soapUI log" tabs and that error not seen, conclude that successfully got a factory but it built a null testStep.

I haven't built from source to take this further but hopefully the above will help (a) others get past this problem and/or (b) help Eviware fix the bug / recommend against this practise if considered bad :-)

Thanks & HTH, R.

No comments:

Post a comment