MikeLoundes
12 years agoContributor
[R] Cannot invoke method getTestCaseByName() on null object
Hi folks
I've had a search about but cant seem to find the answer for this
in a nutshell I have a soapui project that I use from several other projects, this is due to the reference project containing data extractions that are common to multiple other projects so I've kept them in one place
I've noticed that when running a project that calls the reference project from within the GUI all is well as long as I have the reference project open, if closed I get the cannot invoke method error, this isn't a big issue for me in general but as we are now trying to run tests via CI on the back of a build using maven & Hudson the error crops up and is a more serious issue for us
I've found posts relating to running setup test projects but I've tried to use some of that info as a reference and I'm hitting brick walls
the code snippet below has been truncated with respect to the list of properties I'm getting back from the test case execution
any help is very much appreciated
thanks
Mike
for ref I get the error on the line -
I've had a search about but cant seem to find the answer for this
in a nutshell I have a soapui project that I use from several other projects, this is due to the reference project containing data extractions that are common to multiple other projects so I've kept them in one place
I've noticed that when running a project that calls the reference project from within the GUI all is well as long as I have the reference project open, if closed I get the cannot invoke method error, this isn't a big issue for me in general but as we are now trying to run tests via CI on the back of a build using maven & Hudson the error crops up and is a more serious issue for us
I've found posts relating to running setup test projects but I've tried to use some of that info as a reference and I'm hitting brick walls
the code snippet below has been truncated with respect to the list of properties I'm getting back from the test case execution
any help is very much appreciated
thanks
Mike
for ref I get the error on the line -
testCase = testSuite.getTestCaseByName(TargetTestCaseName);
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
//get current project/suite/case names
def CurrProjectName = testRunner.testCase.testSuite.project.name;
def CurrSuiteName = testRunner.testCase.testSuite.name;
def CurrTestCaseName = testRunner.testCase.name;
//log.info "CurrProjectName = " +CurrProjectName;
//log.info "CurrSuiteName = "+CurrSuiteName;
//log.info "CurrTestCaseName = "+CurrTestCaseName;
//get vars
def customerReferenceNumber = testRunner.testCase.getPropertyValue( 'customerReferenceNumber' )
def schemaRefName = testRunner.testCase.getPropertyValue( 'schemaRefName' )
def contractReferenceNumber = testRunner.testCase.getPropertyValue( 'contractReferenceNumber' )
//Project and Test Suite References
def TargetProjectName = "DB Ref Data";
def TargetTestSuiteName = "Generic DB Queries reference";
def TargetTestCaseName = "Get Party Details";
//get test case from other project or from the same one
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName(TargetProjectName);
testSuite = project.getTestSuiteByName(TargetTestSuiteName);
testCase = testSuite.getTestCaseByName(TargetTestCaseName);
//set properties
testCase.setPropertyValue('customerReferenceNumber', customerReferenceNumber);
testCase.setPropertyValue('schemaRefName', schemaRefName);
testCase.setPropertyValue('contractReferenceNumber',contractReferenceNumber);
// run test case
runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
//get property values
def TransproductHoldingRoleType = testCase.getPropertyValue('productHoldingRoleType');
def TranspartyType = testCase.getPropertyValue('partyType');
def TransPartySourceSystemId = testCase.getPropertyValue('PartySourceSystemId');
...
//reset project refs
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName(CurrProjectName);
testSuite = project.getTestSuiteByName(CurrSuiteName);
testCase = testSuite.getTestCaseByName(CurrTestCaseName);
//update test case properties
testRunner.testCase.setPropertyValue('productHoldingRoleType', TransproductHoldingRoleType);
testRunner.testCase.setPropertyValue('partyType', TranspartyType);
testRunner.testCase.setPropertyValue('PartySourceSystemId', TransPartySourceSystemId);
...