Forum Discussion

eflyerman's avatar
eflyerman
Occasional Contributor
7 years ago
Solved

Iterative data driven CI

I'm sure I'm not the first to ask this question however I don't see an answer here.

 

We want to incorporate TC as part of the CI cycle.  Our tests create data that can only be created once i.e. users, products, documents etc.  Subsequent tests with the same data will fail.  We can generate hundreds of rows of test data and specify on the data loop only to run row 1 of the test data. The next iteration, we have to change the keyword test data loop to use row 2 and repeat for every execution.  This manual process won't work in an automated CI cycle.

 

I've ditched the keyword test and written javascript to use the excel drivers for the data loop.  How can I pass the starting row number from the CI tool (Jenkins) on the command line?  Do I have to write the value to a text file and read the text file in the javascript to load it into a project variable?

 

TIA

  • Hi,

     

    There are two ways you to achieve your scenarios,

     

    Way #1:

     

    In Jenkins, TestComplete build step you can additional command line arguments to get your value into TestComplete.

     

    Step 1: Add a parameter for your jenkins build

    Step 2: Use that parameter in additional command line arguments, as like below

    Step 3: In your project suite, Create a OnStartTest event, add below code into that

    function GeneralEvents_OnStartTest(Sender)
    {
          Project.Variables.StartRow = returnParamValue("StartRow");
    }
    function returnParamValue(strParamName){
          for(var i = 0 ; i < BuiltIn.ParamCount() ; i++){
                var currentParamName = BuiltIn.ParamStr(i);
                if(aqString.Find(currentParamName,strParamName,0,true) != -1 ){
                        var arr = currentParamName.split("=");
                        return arr[1];
                }
          }     
    }

    Step 4: Now you can use your Project.Variables.StartRow.

     

    Way #2:

    As you mentioned in the getting value from some text file. In this scenario, when you run in jenkins it is difficult to give dynamic path.

     

    I would prefer 1st way which is very dynamic and easy to understand but need some time for initial setup.

     

     

     

2 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    There are two ways you to achieve your scenarios,

     

    Way #1:

     

    In Jenkins, TestComplete build step you can additional command line arguments to get your value into TestComplete.

     

    Step 1: Add a parameter for your jenkins build

    Step 2: Use that parameter in additional command line arguments, as like below

    Step 3: In your project suite, Create a OnStartTest event, add below code into that

    function GeneralEvents_OnStartTest(Sender)
    {
          Project.Variables.StartRow = returnParamValue("StartRow");
    }
    function returnParamValue(strParamName){
          for(var i = 0 ; i < BuiltIn.ParamCount() ; i++){
                var currentParamName = BuiltIn.ParamStr(i);
                if(aqString.Find(currentParamName,strParamName,0,true) != -1 ){
                        var arr = currentParamName.split("=");
                        return arr[1];
                }
          }     
    }

    Step 4: Now you can use your Project.Variables.StartRow.

     

    Way #2:

    As you mentioned in the getting value from some text file. In this scenario, when you run in jenkins it is difficult to give dynamic path.

     

    I would prefer 1st way which is very dynamic and easy to understand but need some time for initial setup.

     

     

     

    • eflyerman's avatar
      eflyerman
      Occasional Contributor
      This:
                  var currentParamName = BuiltIn.ParamStr(i);            

      is exactly what i was looking for; the missing piece.

       

      Thank you.