Forum Discussion

twice's avatar
twice
Occasional Contributor
7 years ago

Data driven keyword test with variable data

I have a data driven keyword test, which is supposed to be called from several other keyword tests but use different data files depending on the context.   Is there a way to set the source files ...
  • AlexKaras's avatar
    AlexKaras
    7 years ago

    Hi,

     

    > to set the db table variable to a new value

    You asked generic question and got generic reply.

     

    'Set Variable Value' is not the only operation available for the keyword test.

    For example, you may create a variable within your keyword test (Variables tab) and assign it the reference to the required DB Table project variable via the 'Run Code Snippet' operation. (It will be something like KeywordTests.YourTest.Variables.Var1 = Project.Variables.ProjDBVar1)

    You may still use test parameter to define what DB Table variable to use. This can be done, for example, with the help of 'If...Then' operation.

    Alternative approach is to pass the name of the required DB Table variable as a string parameter and resolve it in the test using evaluate() or eval() function, depending on the script language of your test project. In this case the above code statement will look like this (assuming that test parameter was assigned the 'Project.Variables.ProjDBVar1' value):

    KeywordTests.YourTest.Variables.Var1 = evaluate(KeywordTests.YourTest.Parameters.Param1)