Forum Discussion

VeJaay's avatar
VeJaay
Occasional Contributor
6 years ago

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.

  • 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)
    • VeJaay's avatar
      VeJaay
      Occasional Contributor

      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)
      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

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