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 when calling the keyword test?

 

Thanks in advance for your time and effort!

  • 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)

     

    • twice's avatar
      twice
      Occasional Contributor

      Hi,

       

      thanks for your reply.

       

      So you mean I would add a parameter to my test, which I would then use to set the db table variable to a new value? The problem with that is, that the existing "Set Variable Value" function does not seem to work for db table variables.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        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)