Creating a custom Delay teststep via a Groovy scripting step
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Creating a custom Delay teststep via a Groovy scripting step
I managed to create a custom Delay test step via Groovy script but I can't seem to modify the step.
def stepName = "DelayTimeWindow"
def newPropertiesStep = testCase.getTestStepByName(stepName)
if (newPropertiesStep == null)
{
newPropertiesStep = testCase.addTestStep('delay', stepName)
}
I can't seem to modify the actual delay value (in milliseconds) nor am I able to disable the test step from the normal sequential execution of the test case after I create it via code.
I need to be able to set up a dynamic delay based on a value set by the 'main' script I have in the test case. The custom delay step is needed to be called by another (disabled) test step which is triggered by the 'main' test step calling it via the runTestStepByName() function.
I've tried to use Thread.sleep() but it seems to have messed up the whole test case when it woke up after that sleep(). I wasn't even getting proper logging info on the script log window at the bottom of the screen after that.
The test case contains multiple test steps that are all in the disabled state and only called via one main, active Groovy test step depending on multiple variables from an input spreadsheet and many of the test steps are being reused throughout the execution of the test case.
Solved! Go to Solution.
- Labels:
-
Data-Driven Testing
-
Reporting
-
Scripting
-
SOAP
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please set the value as dynamic evaluated property as shown below which is using test case level custom property:
Changed custom property value between two tests and the same can be seen in the log timings
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What I mean by disabled is to set the test step to the disabled state so it looks like :
I'm just about to try out your method of setting the Delay property's value to a property expansion syntax
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is no visible property that I can set to change the test step from active to disabled or vice versa. I can only seem to do it when I right click on the test step and then manually selecting either Enable or Disable.
Also, your concept didn't work.
I am not seeing the delays.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I needed to change it to use ${#TestCase#TapTimeWindow} instead of what you used for the value of the delay
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if you are using the way I showed you. May be just try what I showed in my screen shot.
Define custom property test case level and assign value.
For the delay step, assign the value that is shown.
The test case I created with 3 steps to demonstrate.
Step 1, groovy, just log statement to show the time.
Step 2, delay, the one that is needed
Step 3, same as Step1.
Let me know if the same doesn't work as is.
Mean while I see your example.
EDIT:
Attaching the test case XML in the link below. You can just import it in test suite to be try.
https://github.com/nmrao/sample-soapui-projects/blob/master/delayTestCase/soapuiTestCaseForDelay.xml
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried the way you are showing, but it still works. Please find the test case link which can be imported into a test suite.
How to use:
- Import xml into test suite and run the Groovy Script test step.
What it does?
- This time, changing the value of CUSTOM_DELAY with in the groovy script and run the Delay step from within Groovy to see the delay is changed or not dynamically.
- Also Delay step is activated / deactivated and activated back to demonstrate. As you pointed you could not disable in you messages.
- In the below screen shot, you can notice the log time difference
- Initial value of property is 1s
- Test run #1 with 3sec delay
- Test run #2 with 10s delay
https://github.com/nmrao/sample-soapui-projects/blob/master/delayTestCase/dynamicDelayInGroovy.xml
Regards,
Rao.
