Forum Discussion

IRISQATeam's avatar
IRISQATeam
Contributor
12 years ago

Accessing a subroutine from another project

I am trying to access a subroutine from another project, so far no success. I have used both “uses” and “useunit”, but I can access subroutines from different units within the same project. How can I access a subroutine defined in other project.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    Add a unit from another project as existing one to the current project (i.e. this unit will be shared between those two projects and changes made in one project will be reflected in the other one) and reference it from the callee unit using the useunit or uses statement depending on the script language used in those test projects.


  • Thanks for your reply. When adding an existing item works fine when there is no involvement of NameMapping.



    Project A:  Unit 1, has its own NameMapping



    Project B: Unit 2, has its own NameMapping,



    When I am do Add -- Existing Item   Unit 1 in Project B, it copies the Unit 1 file into Project B but I can’t run this file as it doesn’t have NameMapping of Project A.



    Is there any other workaround where I can just reference into Project B and just access the Project A units/methods?


  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi,



    > Is there any other workaround [...]

    No, it is not possible to reference a script unit from another project so that this referenced unit used NameMapping from its original project.

    Three options are possible in your case:

    a) Merge NameMapping from those two projects and continue with maintaining one common NameMapping;

    b) Create a copy of the unit in another project and continue with maintaining two copies of code;

    c) Do not use NameMapping in the scrit unit shared between several projects but use coded approach (Find, FindChild, EvaluateXPath, ...) to search for and operate with the tested objects.