Forum Discussion

clay's avatar
clay
Contributor
7 years ago
Solved

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.  Something like...

 

switch(testCondition)

{

    case type1 : RunKeywordTestOnly(); break;

    case type2:  RunProjectFolderA(); break;

    case type3:  RunProjectFolderB(); break;

    default: RunProject(); break;

}

 

I don't see any Project object methods to do this.  It looks like one can only run keyword tests programmatically.

 

If the solution is to loop through the Project folders and subfolders to execute the tests, then how does one distinguish between a fold test item and a KWT test item in the hierarchy??

 

Thanks.

 


  • 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".

10 Replies