Forum Discussion

tomaszarmata's avatar
tomaszarmata
Contributor
10 years ago

How to get TestCase property from diffrent TestCase

Hello,

 

I have test structure like this:

 

 

* TestSuite1
** TestCase1
*** TestCase1Property1
** TestCase2
*** TestCase2Property1

When I tried to get TestCase1Property1 by "PPM > get Data" it returns:

 

 

context.expand( '${#[TestSuite1#TestCase1]#TestCase1Property1}' )

Is there any way to do that a little bit more dynamic? Like it returns when I want to get property from the same TestCase:

 

 

context.expand( '${#TestCase#TestCase2Property1}' )

 

 

 

So I want to use TestSuite instead of TestSuite1. Should work something like this?

 

context.expand( '${#[TestSuite#TestCase1]#TestCase1Property1}' )

 

5 Replies

  • Use the point and click feature (right-click > Get data) feature to create the property to another testcase:

    PointAndClick to get prop from other test case.png

    • tomaszarmata's avatar
      tomaszarmata
      Contributor

      I mean "right-click" while writing "PPM". So that is what I mentioned and what is not satysfying me.

      • GillerM's avatar
        GillerM
        Icon for Staff rankStaff

        So if you're not looking at other testcase by name, there should still be some way to reference where you want to get your property value.  There's another option of browsing to a testcase by position / order in the project.  Here's sample code in Groovy step to do that:

         

        // browse up to project object
        def proj = testRunner.getTestCase().getTestSuite().getProject()
        // now browse to positional testcase property by name
        def propValue = proj.getTestSuiteAt(0).getTestCaseAt(1).getProperty("propertyName")
        // now browse to positional testcase property by position
        def propPosition = proj.getTestSuiteAt(0).getTestCaseAt(1).getPropertyAt(0)

        If that still does not satisfy you, then please be very explicit in what you are trying to achieve.  Also in how exactly you look to impletement what you are trying to achieve.

    • jbuttimer's avatar
      jbuttimer
      Contributor

      This is the correct way to do this. You should be able to go all the way up the tree to the top folder and pick up the data anywhere along the way. 

       

      If you do not find this to your liking, I wrote a simple groovy script that grabbed the data I needed for other test cases and suites and wrote it to the Global Variable table. Preferences/Global Variables Then I can pick it up from anywhere by grabbing it from the Global Variable list. 

       

      You didn't say which version you are using which would be helpful. I have ReadyAPI! v 1.4.1 Pro version. 

      • tomaszarmata's avatar
        tomaszarmata
        Contributor

        I have 1.4.1 SoapUI NG Pro.

         

        Im trying to fill up headers in REST Request test step by "right-click" > "Get Data". And I dont like this static reference like:

         

        ${#[TestSuite1#TestCase1]#TestCase1Property1}

        Becouse when I rename testSuite to TestSuite2 I have to change that path in all my testCase REST Requests steps.

         

        Additional groovyScript steps or propertyTransfer can help I think but its not what will make me happy a lot ;)

         

        But if soapUI do not provide little more dynamic way to do this I will do what You suggested.