Loops...

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in SOAtest
Controlling Scenario with a loop
Quick question: I’d like to have a loop that controls how many times a Scenario runs. I need to do something like this:

While notDone

Test 1: IntA Baseline test

Test 2: IntB Baseline test

Compare XML – Compare results from test 1 & 2 and sets notDone = false when XML’s match

While end

The loop will continue until the XML created from IntA and IntB compare 100%. I’ve created a Global Test variable called “notDone” and I want to have a max loop (retry’s) =10.

Is there an easy way of doing this?

Here is the output from a structure report

Test Suite: Automated testcases for Shopping (Data Driven)
Scenario: Validate responses - Roundtrip Itineraries
Scenario: IntA Baseline
Test 1: IntA Baseline test
Response Traffic->XML Data Bank
Response Traffic->Write File

Scenario: IntB Baseline
Test 1: IntB Baseline test
Response Traffic->XML Data Bank
Response Traffic->Write File

Scenario: Redevous - Compare XML
Test 1: Diff
Tagged:

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Good morning Robert,

    The functionality you are looking for is the Execution Options, and it is documented under "Help > Documentation > Functional Testing (Emulating the Client) > Customizing Test Suites > Configuring Test Suite Properties > Execution Options."

    In short, this functionality enables the user to set conditions for how the tests are run. You can also set transient test variables using Method scripts that the Execution Options rely upon, which is described here: http://forums.parasoft.com/index.php?showtopic=1406

    Hopefully, this will give you the flexibility of operation that you need for your testing setup. Another user who had a similar need had a thread here, and it may be helpful for you to look at the example provided there.
    http://forums.parasoft.com/index.php?showtopic=1811

    Regards,
    Joseph
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Thanks Joseph,

    I had gone through that part of the documention and it was somewhat clear....I created a global variable called "Done" with a value = false, next I set the test case logic like so:

    ===============================
    flowtype = while

    max = 50

    While
    Done == False

    do
    Negate

    ===============================

    In my Compare XML scenario, I have it set up as:

    Done == True
    ===============================

    The Compare XML scenario is an XML Diff, so I'm comparing the responses from two different XML requests...I'd like then whole scenario to loop until the results match.

    robert
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hello again Robert,

    If I understand your setup correctly, you are currently trying to use a Method tool to set your test variable 'Done' to TRUE only if the Diff tool passes. In this case, can you not simply add a Method tool after the Diff tool (in the same scenario), and then use the Test Flow Logic to only run that Method tool if the Diff tool is a success?

    To summarize:
    1. Create Method tool (with script) after the Diff tool, but within the same scenario
    2. Go to "Compare XML Scenario > Execution Options > Test Flow Logic"
    3. Set the Method's Test Result Dependency to the Diff Tool, based upon success.

    This way, the Method tool will only set "Done" to TRUE if the Diff tool passes, and the Diff tool only passes when both the previous IntA and IntB pass.

    If this is not what you are looking for, please include your .tst file in your next post so that I can see for myself what you are trying to do.

    Regards,
    Joseph
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Joseph

    I believe your 99% there....here is my .tst file for your review.

    Robert
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    I sorta understand the logic and need to work on it a bit...btw, the method script would be an output for the Diff right? Also, I don't exp. right java or python scripts to place in here....any suggestions? It sounds like if you need to do any kind of "advanced" logic (if you have exp using Silk, QTP, WinRunner, etc) then your going to have to write you own scipts and use it in a Method.

    Robert
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    I have looked at your .tst file, and see that you have the testing steup mostly done. Aside from the script to set the "Done" variable, everything looks like it should run as you expect. Unfortunately, I cannot test it to be sure, as you are using local services that I cannot access.

    Regardless, I have included the Method tool in the attached .tst file that should execute the behavior that you are looking for. Note that I've also changed the Test Flow Logic in "Scenario: Redevous - Compare XML" so that the Method tool will only run if the Diff is successful, which is what I believe is what you want.

    Hope this helps,
    Joseph
  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    edited December 2016
    Joseph

    Its working like a charm!!!! Will contiune to test and see how it goes...but I think this solves my problem. Thanks.

    Robert
Sign In or Register to comment.