Forum Discussion
Hi derbestebaer,
If you are adding event at TestSuite Leve then write:
testRunner.testSuite.setPropertyValue("Time", "test")
Hope this will work for you.
- derbestebaer7 years agoNew Contributor
Hello HimanshuTayal
You said "If you are adding event at TestSuite Leve then write."
As far as I know the Events (menu at the upper right) are global and i can not specify, that i want to add an event for the TestSuite Level.
We tried to add your line there with different triggers, but nothing happens. So my question still remains, how to i set this Variable though the Events :
- Radford7 years agoSuper Contributor
derbestebaer, I've been able to set a test suite property from the TestRunListener.beforeStep event handler. As a stand-alone example, I did the following:
1) Created a new test suite
2) Added a test suite custom property called "tsProp"
3) Added a TestRunListener.beforeStep event handler with the following script (lots of log statements to aid debugging):
def stepName = testStep.getName() log.info('TestRunListener.beforeStep: About to run test step ' + stepName) def existingValue = testStep.getTestCase().getTestSuite().getPropertyValue('tsProp') log.info('TestRunListener.beforeStep: Existing value of tsProp = ' + existingValue) // Set the test suite property testStep.getTestCase().getTestSuite().setPropertyValue('tsProp', stepName) log.info('TestRunListener.beforeStep: set tsProp = ' + stepName)
4) Added a new test case.
5) Added 5 Groovy Test Steps to the test case all with the identical script just to display the current value of the test suite property:
def tsProp = context.expand( '${#TestSuite#tsProp}' ) log.info('Groovy Script Test Step: tsProp = ' + tsProp)
On running the test case I got the following log output (the test suite property was blank when I ran the test case):
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: About to run test step Groovy Script 1
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: Existing value of tsProp =
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: set tsProp = Groovy Script 1
Wed Oct 31 17:14:46 GMT 2018:INFO:Groovy Script Test Step: tsProp = Groovy Script 1
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: About to run test step Groovy Script 2
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: Existing value of tsProp = Groovy Script 1
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: set tsProp = Groovy Script 2
Wed Oct 31 17:14:46 GMT 2018:INFO:Groovy Script Test Step: tsProp = Groovy Script 2
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: About to run test step Groovy Script 3
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: Existing value of tsProp = Groovy Script 2
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: set tsProp = Groovy Script 3
Wed Oct 31 17:14:46 GMT 2018:INFO:Groovy Script Test Step: tsProp = Groovy Script 3
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: About to run test step Groovy Script 4
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: Existing value of tsProp = Groovy Script 3
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: set tsProp = Groovy Script 4
Wed Oct 31 17:14:46 GMT 2018:INFO:Groovy Script Test Step: tsProp = Groovy Script 4
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: About to run test step Groovy Script 5
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: Existing value of tsProp = Groovy Script 4
Wed Oct 31 17:14:46 GMT 2018:INFO:TestRunListener.beforeStep: set tsProp = Groovy Script 5
Wed Oct 31 17:14:46 GMT 2018:INFO:Groovy Script Test Step: tsProp = Groovy Script 5Compare my scripts to yours and see how you get on.
- derbestebaer7 years agoNew Contributor
Hello Radford,
Thank you very much. That helped me a lot. I managed to set the Testsuit variable via an event Script.
Two points are still missing for me:
1. For our testing, we use soap ui in a way, in which we run every Teststep manually. Since you already used the event "TestRunListener.beforeStep " i expected that the event would also be triggered, if i run a teststep (SendSyncData) manually, but it seems, that the Testsuitvariable tsProp gets only written, when i run the whole Testsuite. I tried different events i.e. LoadTestRunListen.beforeTestStep but i dont get the event triggered by running the TestStep only.
2. Where can i find the outputconsole from ´your logfile bellow? If i add a groovy script i can see a console but this console is only for the current teststep. If i rightclick on the Testsuit and select "Groovy Console" i dont get any output there.
Thank you very much in advance.
Daniel
Related Content
- 15 years ago
Recent Discussions
- 2 hours ago
- 5 days ago