Forum Discussion

Kamal_chennai's avatar
Kamal_chennai
Contributor
10 years ago

How can i access other projects script routine

Hi,

i have a two projects like "Test1", "Test2". the script routine was created in "Test2". i may access the Test2's script routine via "Add Existing Item"(i.e.,Reference.png ) i dnt want that method. now i want to call Test2's script routine function in Test1 Keyword. is it possible???



  • Hi Kamal,



    Did you manage to access the links provided? In any event... So.... you have (in your example) 2 projects. Let's say you created In project 2 (in your case Test 2) a script routine that you now want to "call" in Test 1. As per [http://support.smartbear.com/viewarticle/56535/] this is not technically possible. You have some options available to get past this:


    • Add a script unit that contains the routines defined in the other project (you will have to copy and paste (the problem i have with this is maintenance).


    • You can create a "library"  unit and add them to your projects as needed.


    Another option (that i prefer) is to write an extension for TestComplete. If you have routines (functions) that you use accross different projects, it would make sense to store these functions in 1 location. Have a read through this resource.



    The simplest way for you to achieve your goal is the simply copy and paste the routine (function) to the other unit in the other project.



    Hope this clears it up somewhat :)



    Altus
  • Hi there,



    This is what you are looking for and you should have a look at this as well.



    Hope this helps!

    Altus
  • Hi Kamal,



    Did you manage to access the links provided? In any event... So.... you have (in your example) 2 projects. Let's say you created In project 2 (in your case Test 2) a script routine that you now want to "call" in Test 1. As per [http://support.smartbear.com/viewarticle/56535/] this is not technically possible. You have some options available to get past this:


    • Add a script unit that contains the routines defined in the other project (you will have to copy and paste (the problem i have with this is maintenance).


    • You can create a "library"  unit and add them to your projects as needed.


    Another option (that i prefer) is to write an extension for TestComplete. If you have routines (functions) that you use accross different projects, it would make sense to store these functions in 1 location. Have a read through this resource.



    The simplest way for you to achieve your goal is the simply copy and paste the routine (function) to the other unit in the other project.



    Hope this clears it up somewhat :)



    Altus
  • Ravik's avatar
    Ravik
    Super Contributor
    Yes, it’s possible. If you have several test projects, you may want to use the same routines from one project in other ones. The uses (or USEUNIT) clause added to a unit, lets you refer to routines defined in other units of the same project.



    If you need to call routines defined in a unit from another project, you should add a unit that holds these routines to your project. To do this, right-click the Script project item in the Project Explorer panel and choose Add | Existing Item from the context menu. This will display the standard Open File dialog where you can specify the unit to be added.   


    If the unit includes routines that you do not want to “export”, you can create a new unit by selecting New Unit on the Units toolbar, copy the needed routines to this unit and then add the new unit to the desired project. You can even create a unit “library”, that is, units that hold the desired routines, and then add these units to any project you want.