cancel
Showing results for 
Search instead for 
Did you mean: 

Need help in placing a script in tear down script.

SOLVED
Highlighted
Occasional Contributor

Need help in placing a script in tear down script.

I am generating report for each and every test case. The code for the report is placed in the tear down script. I make frequent changes to the report and its very difficult to change the code every time. So I thought of placing the code in the property and accesssing in the tear down scipt. I am able to get the value from the property but not sure how to run it. Sopa UI is considering it as plain text. Any help to fetch code from property in tear down script and make it run would solve my issue.

1 ACCEPTED SOLUTION

Accepted Solutions
Occasional Contributor

Re: Need help in placing a script in tear down script.

Thanks @JoostDG  for your help. But what I was looking is to place a report script in the teardown script using groovy code.I have found it and its working

 

Here is the code : 

 

testRunner.testCase.testSuite.project.getTestSuiteByName('Library').getTestCaseByName('Test2').setSetupScript('log.info "34324234"')

def script = context.expand( '${#[Library#Test1#te]#script}' )

log.info script

testRunner.testCase.testSuite.project.getTestSuiteByName('Library').getTestCaseByName('Test2').setTearDownScript(script)
3 REPLIES 3
Contributor

Re: Need help in placing a script in tear down script.

Hi Veejay.

 

It looks to me that the functionality you're looking for is actually this: https://support.smartbear.com/readyapi/docs/testing/scripts/library.html

 

You want a script library so you can maintain your piece of code on 1 place instead of "at every single place where you use it".

Occasional Contributor

Re: Need help in placing a script in tear down script.

Thanks @JoostDG  for your help. But what I was looking is to place a report script in the teardown script using groovy code.I have found it and its working

 

Here is the code : 

 

testRunner.testCase.testSuite.project.getTestSuiteByName('Library').getTestCaseByName('Test2').setSetupScript('log.info "34324234"')

def script = context.expand( '${#[Library#Test1#te]#script}' )

log.info script

testRunner.testCase.testSuite.project.getTestSuiteByName('Library').getTestCaseByName('Test2').setTearDownScript(script)
Community Manager

Re: Need help in placing a script in tear down script.

Thanks for sharing your solution with us, @VeJaay! I'm sure it will help other users in the future.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
New Here?
Join us and watch the welcome video:
Top Kudoed Authors