Forum Discussion

AndyHughes's avatar
AndyHughes
Regular Contributor
13 years ago

Copying properties to multiple test cases and steps

Is there a way of duplicating test case properties to multiple test cases at the same time? I know you can load properties from a file, but it all seems to be to one test case and test step at a time. I need to do the same thing to around 400 test cases??

7 Replies

  • Why do you want to dulicate them? Is it just so they can all access the same data? If so then just use project or test suite properties which can be accessed by all (chidren) test cases.
  • AndyHughes's avatar
    AndyHughes
    Regular Contributor
    This would be good but what I want to do is output these properties in a load test in LOADUI, but in LOADUI I can only output test case properties as opposed to test suite properties.
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    You can use setup script at a test suite level. So when you kick off the execution from a test suite, it can read the properties and set all the children test cases with those properties. Does that work?
  • AndyHughes's avatar
    AndyHughes
    Regular Contributor
    Haha. It might do. But I'm afraid you're beyond my knowledge there. Unless you have time to explain more.?
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    Okay. Here you go for the long answer:

    Every Test Suite and test case has something called setup script and tear down script. Both are groovy scripts which as the name suggests are run before and after the running of test suite/case respectively. If you open test suite by double clicking it, look for "setup" right above where you would get log. The editable area is too less so you will have to expand it. This setup script on a test suite level will can set properties at all 400 test cases level from a for loop since all these test cases would probably be under this same test suite. Does that make more sense?

    Regards,
    Deepesh
  • AndyHughes's avatar
    AndyHughes
    Regular Contributor
    I don't want to set properties for a test case (which I think is what you are describing). I want to export the value of a test case property after the test case is run.
    Essentially I have 2 properties at test case level, one called 'Request' and one called 'Response'. They are populated by a property transfer, the source for them is the test case 'request' and 'response' respectively.
    These test case properties are output in loadui. But the contents is obviously different for each test case.

    All I want to do is to make it so that each test case has the properties 'Request' and 'Response' so that these variables can be 'populated' by the running of the test case.
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    I am assuming both these properties are XML's. Once again as earlier, you can access the properties themselves from groovy script like below:

    pvalue = testRunner.testCase.getPropertyValue("Property_Name");

    You can name your test cases in an array like fashion and than call a for loop to pass these properties to the test cases.

    Regards,
    Deepesh Jain