Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
8 years ago

Question: Run a test with empty parameters in a loop?

Consider this scenario:

 

I have a keyword test which uses, say, 25 parameters. I want to run this test in a loop so that on each run one of the parameters is left empty.
So, starting on first run, the first parameter is filled with value "", second run the first parameter is used with the default set value, the second parameter is left blank,
going through all the parameters, on each iteration setting one of the parameters to an empty value.
So, the loop is run 25 times.

What whould be the approach you would use?

 

Any tips and ideas would be welcome, and appreciated.

 

Mathijs

11 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Python way:

     

    params = [1,2,3,4,5]
    
    for i in range(len(params)):
        test_set = [param for param in params]
        test_set[i] = None
        print test_set

    Output:

     

    [None, 2, 3, 4, 5]
    [1, None, 3, 4, 5]
    [1, 2, None, 4, 5]
    [1, 2, 3, None, 5]
    [1, 2, 3, 4, None]

    • mgroen2's avatar
      mgroen2
      Super Contributor

      baxatob thanks, but how can I implement this in keyword test framework?

      I don't really "speak" Pyton....

      • baxatob's avatar
        baxatob
        Community Hero

        For example you can create some helper-script (on your preferred language), which will assign required test parameters. Then you can call it from the keyword test in the loop.