Forum Discussion

ray_mosley's avatar
ray_mosley
Frequent Contributor
12 years ago

Reuse Functions in projects

We want to have a TestComplete project suite that has the following structure:

Project Suite TestThe Application 

  Project CommonFunctions

    Script Common

       function A

       function B

  Project AppModule1

     Script TestMain

  Project AppModule2

     Script TestInterface



I need the Project AppModule1 Script TestMain to be able to use function A in the CommonFunctions Project Common script.

I also need the Project AppModule2 Script TestInterface to be able to use function A in the CommonFunctions Project Common script.



How do I do that?



Please do not refer me to article 27356.  Basically that tells me that TestComplete Add | Existing Item copies the unit to be shared into the project.  Doens't that create a maintenance issue where you now have to maintain two separate units?

       

4 Replies

  • frauem's avatar
    frauem
    Occasional Contributor
    Harlan,



    At that point you do not have two seperate units to maintain. Think of the added existing unit in your "AppModule1" and 2 projects as logical links to the Common project. They do not recreate the files in the new project. Our project suite currently works like this and this functionality works very well for us.



    Matt
  • ray_mosley's avatar
    ray_mosley
    Frequent Contributor
    So how does this work? 



    If the code is "shared" like a UNIX symbolic link, what name mapping file is used when the code executes?

    For example, in my example structure:

    Project Suite TestThe Application  

      Project CommonFunctions

        Script Common

           function A

           function B

      Project AppModule1

         Script TestMain

      Project AppModule2

         Script TestInterface



    When AppModule2.TestInterface invokes ScriptCommon Function A, is the NameMapping file that is used the Name Mapping file for Project AppModule2 or for Project CommonFunctions?









  • ray_mosley's avatar
    ray_mosley
    Frequent Contributor
    So how does this work? 



    If the code is "shared" like a UNIX symbolic link, what name mapping file is used when the code executes?

    For example, in my example structure:

    Project Suite TestThe Application  

      Project CommonFunctions

        Script Common

           function A

           function B

      Project AppModule1

         Script TestMain

      Project AppModule2

         Script TestInterface



    When AppModule2.TestInterface invokes ScriptCommon Function A, is the NameMapping file that is used the Name Mapping file for Project AppModule2 or for Project CommonFunctions?









  • Gordian's avatar
    Gordian
    Occasional Contributor
    Look up "Merging Name Mapping files" in the Help.



    I really do not understand why a project can only have a single map file.  I would think it should be able to search through all of them listed in a project to find definitions/aliases.



    The result of the merge is that now your definitions/aliases are merged into multiple projects which makes maintenance more difficult.



    Does anyone have a better strategy for reusing common functions that rely upon name mapping?