Forum Discussion

enliven's avatar
enliven
Contributor
17 years ago

Update/Refactor definition messes up TestStep Groovy Script ...

I might just be doing something wrong and this is not a bug, but here is what happened:

Updated Definition, Refactored (made minor corrections), tried running test cases and found that ANY groovy script using context expansion with xpath embedded was messed up. Also, none (that Ive come across yet) of the assertions with context/xpath were modified.

Before:
def currentTearDownCmd = context.expand( '${#TestCase#TearDownCmdText}' )
def newTearDownCmd = currentTearDownCmd + " Delete from XXX where groupID = " +  context.expand( '${SettingsGroup_Create#Response#//ns2:DriverSettingsGroup_InsertResponse[1]/ns1:DriverSettingsGroup_InsertResult[1]/@id}' ) + ";"
testRunner.testCase.setPropertyValue("TearDownCmdText", newTearDownCmd)



After:
def currentTearDownCmd = context.expand( '${#TestCase#TearDownCmdText}' )
def newTearDownCmd = currentTearDownCmd + " Delete from XXX where groupID = " +  context.expand( '${SettingsGroup_Create#Response#declare namespace ns2='http://fwapi.ZZZ.com/AdminService_v2';
declare namespace ns1='http://fwapi.ZZZ.com/CommonTypes/2009/04';
//ns2:DriverSettingsGroup_InsertResponse[1]/ns1:DriverSettingsGroup_InsertResult[1]/@id}' ) + ";"
testRunner.testCase.setPropertyValue("TearDownCmdText", newTearDownCmd)

2 Replies