Forum Discussion

bqualters's avatar
bqualters
Occasional Contributor
3 years ago

Dynamic property value setting causing Failure

I am REALLY new to SoapUI and writing Groovy scripts.  I am trying to see if I can change a TestCase Property at runtime using a setPropertyValue command at the Testcase level...to ensure it actually got switched before executing the step with a run command I do a get and write out a log statement to make sure it is set to what I wanted and it does reflect the changed value - but the execution of the Groovy script causes the Request to fail.   If I manually execute the test Request it works as expected...

 

tcase = testRunner.testCase.testSuite.testCases[currTest]; //create object to store test case
tstep = tcase.getTestStepByName(it.Name); //create object to store test step

 

def PrimaryKey = tcase.getPropertyValue("TheHexPOKey")
def PrevExpKey = tcase.getPropertyValue("ExpKey")
def RealPOKey = "0000000645"
log.info (" The current Primary Key value retrieved from Test Case property TheHexPOKey is -->" + PrimaryKey +" and the current ExpKey value is "+PrevExpKey)

 

tcase.setPropertyValue("TheHexPOKey",PrimaryKey)
tcase.setPropertyValue(SubStepValueIs,RealPOKey)

 

PrimaryKey = tcase.getPropertyValue("TheHexPOKey")
PrevExpKey = tcase.getPropertyValue("ExpKey")
log.info (" The current Primary Key value retrieved from Test Case property TheHexPOKey is -->" + PrimaryKey +" and the current ExpKey value is "+PrevExpKey)

 

The code above does what is expected - finds what the values are before changing, then changes the value, checks to make sure the changes are applied

status = tstep.run(testRunner,context);
result = status.getStatus().toString();

 

CurrStepResponse = tstep.getPropertyValue("ResponseAsXml");

log.info(" "+CurrStepResponse)

 

and EVERYTIME this shows in the log-->

<Fault xmlns="****with the name of the WADL here***">
<Message>An error has occurred.</Message>
</Fault>

 

WHY?  Can anyone assist a newbie with an answer that a NEWBIE can understand?

 

No RepliesBe the first to reply