Forum Discussion

lslechta's avatar
lslechta
Occasional Contributor
7 years ago
Solved

Is there a way to get a table variable to auto generate the next time a keyword test is run?

Is there a way to get a table variable column value to auto generate the next time a keyword test is run?

For example, I run the test once and have a variable table value field set with a city name. Once the test is run the city name is saved to the database.  When I run the test a second time my database will not allow a duplicate name to be saved. Is there a way to auto generate a new city name the next time I run the test or do I have to manually do that by going to the variable on the keyword test and generate a new random name?

Please see my attached screenshot to see the field I'm referring to.

  • When you define a table in that way, it is a static table.

     

    What I would do is, when you use that value in your test, add some sort of unique identified value to the end of the data you get from the table before you use it... if that's possible.

     

    Alternatively, at the end of your test run (or the beginning of a new one), perform some sort of "reset" of the data in your application under test so that it is no longer subject to the data duplication check. For example, in a previous "life", at the start of a test run, we restored an SQL database from back up which contained a "baseline" of data so that any tests that followed would avoid any of this duplication of data.

2 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    If you're never going to allow duplicates, then table variable may not be your best approach. The table variable would let you choose from a list of 1 to SomeSize and get the value of each variable.

     

    For only one row, you might as well have a local variable for each of the 5 fields and generate a new string for them each time.

     

    In your case, if Lab Name is the only one that needs to be unique, you could generate a string for it every time and just put a value in the other four variables that never changes.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    When you define a table in that way, it is a static table.

     

    What I would do is, when you use that value in your test, add some sort of unique identified value to the end of the data you get from the table before you use it... if that's possible.

     

    Alternatively, at the end of your test run (or the beginning of a new one), perform some sort of "reset" of the data in your application under test so that it is no longer subject to the data duplication check. For example, in a previous "life", at the start of a test run, we restored an SQL database from back up which contained a "baseline" of data so that any tests that followed would avoid any of this duplication of data.