Forum Discussion

Janine_Billings's avatar
Janine_Billings
Occasional Contributor
16 years ago

Re: SOAPUI Test case flow

Hi
I'm looking for some best practices when creating SOAUI test suites.
In the following data drive scenario whereby you can have multiple flavours of the same request in a test case and would like to branch to a given test case depeneding upon the data input. In the following example

data: product, promotion, type

purchaseProduct - without promotion
purchaseProduct - with promotion
purchaseProduct - with type defined ... and so on

So using the pro features you could have each of the flavours of the purchaseProduct service in the dataSourceLoop and then groovy branches and exits as follows

DataSource
Groovy Branch
purchaseProduct1
Groovy Exit
purchaseProduct2
Groovy Exit
PurchaseProdcut3
Groovy Exit
Other request1
And so on
DataSourceLoop


In a test case there maybe multiple flavours of the same requests, which then means multiple branches and exit groovy scripts, which soon build up a number of steps for a simple branch. My question, is there a more efficient way of scripting such a data driven suite. I have been working on a purely dynamic suite which will build the requests based on the data input, but we really do need to be able to make use of the pro feature also


Thanks
Christopher

4 Replies

  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Sounds like you want something like a SWITCH step that could select a single request to execute...

    DataSource
    Select Step (selection logic here)
        purchaseProduct1
        purchaseProduct2
        PurchaseProdcut3
        Other request1
    End Select
    DataSourceLoop
  • Janine_Billings's avatar
    Janine_Billings
    Occasional Contributor
    Thanks for the reply again!
    Ok, using a switch statement would be fine for requests purchaseProduct1 - to purchaseProduct3, however the 'other request1' should be executed after purchaseProduct1 - to purchaseProduct3 branch has been executed, the switch statement would not allow this there would still need to be a groovy script to go to the other request step. Also On the last iteration the flow would drop through all requests, so I have put the groovy exit step in to prevent this from happening. I can get this to function as required; I'm looking for a more efficient use of the soapui features to prevent a large number of steps in a given test case

    Sorry my explanation is probably not the best, thanks again!
    Christopher
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Not that this exists (it doesn't, maybe it should be a feature request) but if it was couldn't you just move the other request outside the select?

    DataSource
    Select Step (selection logic here)
        purchaseProduct1
        purchaseProduct2
        PurchaseProdcut3
    End Select
    Other request1
    DataSourceLoop
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    How about this:

    Given a test case like that in the image, put this code in the 'Select TestCase' step:

    def selectedStep 
    // do some logic to figure out step to be exectuted, say Step 2
    selectedStep = "Step 2"

    testRunner.runTestStepByName(selectedStep)
    testRunner.gotoStepByName("End Select")


    This will execute the selected step, then resume execution at the End Select step, skipping the steps in between.