Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Scripting - Dynamic Input for Concurrent Testing

Options
LegacyForum
LegacyForum Posts: 1,664 ✭✭
edited December 2016 in SOAtest
Dynamic Input for Concurrent Testing
Hello,

I have such an issue,


i should create a test suite with 100 tests which should run concurrently.

In fact all 100 tests are the same , but i want to set an input parameter in the test between data range 2X0X and 3X0X ( X is the any number). So what i want is that : for all the values in that range my test case should work concurrently.

is it possbile to read the only one unique row for each test from a data source (during a concurrently testing)?

or can you suggest a scripting for my problem?


regards
Mete
Tagged:

Comments

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    What you're trying to do is make each of the concurrent tests use a unique value for the input? If this is correct, you could use a script to do this:

    1) Right click on the test suite and choose Add Test->Set-Up Test->Method. The Set-Up test is always run first when the entire test suite is run.
    2) Write a script to generate random values from the range 2X0X-3X0X. Put the values into the context using the test case number as the key. For instance, context.put("1", "2000") would associate the key "1" with "2000" and put it in the context.
    3) For the test case, write a script for the input to get the value from the context. For instance, for test case 1, using context.get("1") would get "2000"

    I've attached an example of how to use the context to store data. You can find more details on SOAtest scripting by going to Help menu->Scripting API. Let me know if you need help writing the script or if I have misunderstood your question.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    Thanks for your quick answer.


    So my next question , how can i pass the testcase number to the script to avoid writing script more than once? Because the number of test case is too much and in real test scenario it will be more than one input parameter generated like that.

    Sample:

    def getFromContext(context,testcaseID):
    return context.get(testcaseID)


    For instance, when i put this script in a file, how can i send the testcaseID parameter to determine the test case?

    or
    it is better if i can also get the parameterNAME which i attached the script, with the test case ID. <_< <br />
    def getFromContext(context,testcaseID,parameterNAME):
    return context.get(testcaseID)




    Thanks in advance.
    Mete
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    sorry last sample should be like:

    def getFromContext(context,testcaseID,parameterNAME):
    return context.get(testcaseID+parameterNAME)
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    I've attached an example test suite that generates random values for multiple inputs and uses the test name and element name as keys for the values. Here are some more details:

    1) The two Set-Up tests generate random values for the elements x and y. The scripts are the same except for the inputElement variable.
    2) The Set-Up tests get the name of every test in the test suite. This is combined with the element name to form a unique key for each test. This key is mapped to the value and put into the test suite context.
    3) For every test, the x and y input is set to a script. The script is the same except for the inputElement variable.
    4) The input script gets the value from the test suite context based on the unique key.

    To add generate random values for another input, just copy the scripts and change the inputElement variable to the element name.
  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    Options
    thanks for the advanced support.


    mete.
  • [Deleted User]
    [Deleted User] Posts: 0 admin
    Options

    The concept in this post is valid, however to make things work would require updating the scripting.