Forum Discussion

Jaroslaw's avatar
Jaroslaw
Contributor
12 years ago

Populate DataSource using DataGen

It is possible to populate a DataSource using a DataGen step?

5 Replies

  • Jasper175's avatar
    Jasper175
    Frequent Contributor
    What exactly are you trying to achieve?
    The dataGen is used directly as an alternative type of Data-Driving like the DataSource.

    Elaborate if you can.
  • I want to loop the HTTP Request test step 10 times. Not using groovy or load ui.


    1. DataGen - Generate a list of numbers 1...10

    2. Data Source

    3. HTTP Request

    4. Data Source Loop
  • Jasper175's avatar
    Jasper175
    Frequent Contributor
    Ok I got it down but you can't do this without Groovy... DataSource is annoying unless you use Excel where you only have the option box "Select if rows containing empty data should be skipped"
    And the problem with DataGen and DataSource is they just want to keep running until you stop it.

    OPTION 1 - If you're the only user of SoapUI then use the Excel and have A1 - A10
    > DataSrouce (with the checkbox mentioned above checked)
    > TestStep (pointing to datasource)
    > DataSourceLoop

    OPTION 2 - DataGen & DataSource w/ Groovy
    > DataGen (set to 1-10)
    > DataSource (groovy)
    def numberDG = context.expand( '${DataGen#Number}' )
    result["number"] = numberDG

    > TestStep
    > Groovy Script
    def rawRequest = context.expand( 'your HTTP rawRequest value that is used' )
    if (rawRequest == "10")
    runner.cancel("End")

    > DataSourceLoop

    *only problem with that is it takes the runner.cancel as a failure - - Not sure how to stop/cancel gracefully

    OPTION 3 - ALL GROOVY *which is the best since it works in the free version also
    > Property (with one field "value")
    > Groovy "SetInterval"
    testRunner.testCase.getTestStepByName("Properties").setPropertyValue( 'value' , '1' )

    > TestStep (pointing to Property "value"
    > Groovy "Loop"
    def rawRequest = context.expand( 'your HTTP rawRequest value that is used' )
    def maxVal = "11" as int
    def value = context.expand( '${Properties#value}' ) as int

    if ( value < maxVal)
    {
    String nv = value + 1
    testRunner.testCase.getTestStepByName( "Properties" )setPropertyValue( "value", nv )
    testRunner.gotoStepByName("getCustomerStatus")
    }


    So there are the options I found that you can do

    Rob
  • Thanks Jasper but I feel we shouldn't need to resort to Groovy for something this simple.

    Could this be moved to the Feature Request board?
  • Jasper175's avatar
    Jasper175
    Frequent Contributor
    That's what went through my mind why the DataSourceLoop is only tied to the DataSource... it should be allowed to use w/ a DataGen, along with a termination option when the maxVal is reached. I agree totally - but as of now I can only see those options as your alternative.
    Let me know if you want me to log it - I'm just a SoapUI customer like yourself.