Forum Discussion

asmatullah's avatar
asmatullah
Contributor
12 years ago

Is it possible to check uncheck Testitems in project using script .

Hi All ,



I have number of test  and their child test items .

Some times i need to run olny selected items from the project items .

To do so i need to check uncheck lots of item ( time consuming )  .

Is there any way to check unchek required test items using script or any smart way .

1 Reply

  • joffre's avatar
    joffre
    Regular Contributor


    Hello!



    It is possible, however, I guess it isn't a good practice.



    Checkout this article: TestItems Object



    Here is the link's example:



    function Test()

    {

      var i, TestItems, Count;

      // Obtains the collection of project test items

      TestItems = Project.TestItems;

      // Defines the total number of test items in the project

      Count = TestItems.ItemCount;

      // Iterates through the project’s test items

      for (i = 0; i < Count; i++)

        ProcessTestItem(TestItems.TestItem(i));

    }



    function ProcessTestItem(ATestItem)

    {

      // Posts the test item name

      Log.AppendFolder(ATestItem.Name);

      // If the test item contains child items, iterates through them

      for (var i = 0; i < ATestItem.ItemCount; i++)

        ProcessTestItem(ATestItem.TestItem(i));

      Log.PopLogFolder();

    }



    I prefer to call USEUNIT on a script, specify the name of the script file from where I want to inherit the functions for. And call all in one script file.



    Like this:



    //USEUNIT BD_UTIL



    function test()

    {

      // BD_UTIL's function

      connectar();

    }



    or like this:

    function test()

    {

      // BD_UTIL's function

      BD_UTIL.connect();

    }



    But when everything is ready, I use the Project TestItems normally.



    Hope it helps.