Forum Discussion

cdunne's avatar
cdunne
Contributor
17 years ago

Dynamic Templated Tests

Hi,

I have a data source where every row represents and holds test data for a particular test case. This data is then looped through a templated request.

I have come across the following issue, one of my templates can be generated in 2 different ways, for example the following method must be generated with only 1 of a choice of 2 elements.


       
              "Blah"
       


or

       
       
              "Blah"
       


The only way I can see round this is to have 2 separate templated scenarios for the same request, either ran in two spearte testcases or teh same test case. I don't really want to split the datasource in two or try to manage the order in which the test case data is populated in either.

I would prefer to keep all the logic with in the test case, so if a Msisdn field in the datasource is populated execute scenario 1 or if the Imsi field is populated, execute scenario 2. Is it possible to dynamically generate templated requests or select which request to run within a test case, based upon a supplied property.

Has anyone tried anything like this before or is it even possible?

Cormac

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Cormac,

    try the following:

    1) Create 2 requests after eachother, one with each option and the corresponding property-expansion from the DataSource
    2) Create a groovy-script before them that checks the data availability and enables/disables the corresponding requests.. something like the following:

    def value1 = context.expand( '${DataSource#Value1}' )
    def value2 = context.expand( '${DataSource#Value2}' )

    def testSteps = testRunner.testCase.testSteps
    testSteps["Request 1"].disabled = value1.length() == 0
    testSteps["Request 2"].disabled = value2.length() == 0

    Hope this helps/works!

    regards,

    /Ole
    eviware.com