Forum Discussion

k_de_boer03's avatar
k_de_boer03
Contributor
10 years ago

Create test items during runtime

Hi, 

I am primarily working in Jscript to execute my testcases. I have my testcases defined in an excel sheet and then parse and execute each in a seperate script project Test Item. This means that I have to manually add a Test Item and create a new script routine every time I create a new testcase in the excel sheet. Essentially I have to manually keep them in sync. 

 

I've been looking for a way (but haven't found anything yet) where I can create a new Test Item programmatically for each testcase in my excel sheet. Then I would have just 1 main Test Item that generates new Test Items on runtime so I don't have to do it manually. In pseudo-code it would look something like:

 

Get all testcases from excel sheet
Create a new Test Item for each testcase
Run each Test Item
Log result for each Test Item back to excel sheet

The main reason I want create new Test Items is so that my event handlers are triggered (the logging happens in OnStopTest handler for each testcase). I can do it within 1 script routine and without creating new Test Items but then my event handlers are not triggered and everything is logged under 1 LogItem.

 

So is there any way (or alternative) to achieve the above scenario?

 

Regards, 

Kevin

 

 

 

 

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    I would say, up front, not exactly as you have described.  TestComplete does not support the addition of test items (script files, keyword tests, etc) during runtime AFAIK.

     

    Since you are already using XLS files, my suggestion to you would be to build some sort of framework using DDT objects in TestComplete that read the XLS files dynamically and execute the tests as indicated.  This is a bit more of an advanced technique and takes some code work to build the structures but the ROI is good.  Once you have the basic framework constructed, all you need to do to add a new test case is to add rows to your XLS files.

     

    So, your psuedo code would be something like:

    Read XLS file(s)
    Build ODT objects or arrays for each test case found in the file(s)
    Execute a code routine to "step" through the list of objects/records
    Output results to XLS file.

    There is a set of topics that will help you down this path at http://support.smartbear.com/viewarticle/56219/.

    If you're interested in something more advanced, I wrote http://blog.smartbear.com/software-quality/automation-framework-a-new-table-driven-technique-using-testcomplete a few years back.  I've developed the framework a little bit past that but I haven't had time to dedicate to making it more application agnostic yet.  As it is, this might be able to do what you want.  I'd be happy to help further in this.

  • So really what you are trying to do is run each of those test items and get separate logs for each?  Is that the only reason you have them in Excel?

    • k_de_boer03's avatar
      k_de_boer03
      Contributor

      I have my testcases in excel mainly due to business requirement. 

       

      I write the testcases and automate it myself using JScript. A new business requirement asks if it is possible for other people who have no experience in TestComplete or JScript to create and run testcases themselves.

       

      If they can follow the testcase template I can give them then the parsing and execution will be OK. But my current implementation makes use of a couple of event handlers (OnStartTest/OnStopTest for example). Not only for logging, but also for error handling and other custom developed features/plugins. I would like to reuse as much of this is possible. These events are triggered for each Test Item. So I require that each testcase has its own Test Item so that the events are properly triggered. 

      The only way I know to make a new Test Item is by adding them manually to the project file using TestComplete. I am looking for a way to do this without them requiring it to do it themselves. 

       

       

       

  • kzoe's avatar
    kzoe
    New Contributor

    Hi Kevin,

     

    Sorry to revive this old thread. How did you solve your problem? I'm facing a similar problem myself where this feature would come in handy.

     

    Thx and best regards,

    K.

    • k_de_boer03's avatar
      k_de_boer03
      Contributor

      Unfortunatly I haven't been able to create a solution for this. I am still required to keep the excel file and test items in sync manually. I assume that is the same problem you are having.

      • mgroen2's avatar
        mgroen2
        Super Contributor

        k_de_boer03, kzoe: Have you thought of creating a feature request for this? I'd be happy to give it a vote (a kudo). If it gets enough kudos Smartbears development team might pick it up in one the next releases of TC....