Forum Discussion

clay's avatar
clay
Contributor
8 years ago

Executing a project from within a script.

Is it possible to execute a the current project from JavaScript?  We have a scenario where we would like to execute a project, or a project folder/subfolder depending upon certain test conditions.  S...
  • tristaanogre's avatar
    tristaanogre
    8 years ago

    cunderw wrote:

    So the Project.TestItems, and TestItems object as mentioned in documentation do not have methods to run them. Only properties about the test item. There are a number of ways though you can control which ones to run.

     

    What is your end goal though? Test items themselves are used to group and run in sequence different tests, so by trying to control this by a script in your project you're kind of defeating the purpose of the Test Items. 


    If you want to control flow, customize test runs via code, etc., the best way to do so is to construct some sort of structure by which you feed in from some data source what test cases you want to run.  It could be something as simple as a single column CSV file with the names of each KeywordTest you want to execute.  A basic loop would then be something like:

     

    var testRun = DDT.CSVFile('C:\\MyDir\\MyFile.csv');
    while (!testRun.EOF) {
        KeywordTests[testRun.Value('TestName')].Run();
        testRun.Next();
    
    }

    Then, every time you want to build a different sequence of tests to execute, you just drop a different version of MyFile.CSV into the directory and click "Run".