Forum Discussion
I think there may be some other factors at play here, I've just tried the following. A test case with two test steps, first a Groovy Script, followed be a SOAP request.
With the full Groovy script test step contents as follows (based on your code):
// Get the SOAP test step. def testStep = testRunner.getTestCase().getTestStepByName('SOAP Request') // Just create a unique name each time, allows the script to be run // multiple times without clashing assertion names. def currentDateTime = new Date() def newAssertionName = currentDateTime.format("HHmmss") log.info('newAssertionName = ' + newAssertionName) // Add the new script assertion. def testAssertion = testStep.addAssertion('Script Assertion') testAssertion.setName(newAssertionName) testAssertion.setScriptText("log.info 'we are running the script assertion ${newAssertionName}'")
This works exaclty as you would expect, adding a new assertion and renaming as expected. With the log output:
Thu Nov 24 17:44:05 GMT 2016:INFO:newAssertionName = 174405
Thu Nov 24 17:44:05 GMT 2016:INFO:we are running the script assertion 174405
Thu Nov 24 17:44:05 GMT 2016:INFO:we are running the script assertion 174405
(Not sure why the assertion is run twice?)
I'm using the same build as you so on the face of it what you are doing seems right. Sorry it's not a solution, just wanted to say that I got your code working correctly.
Related Content
- 7 years agoDonkey2017
- 5 years agoNinjaMarvel
- 6 years agomartonjurak
- 7 years agoDonkey2017