Forum Discussion

Soni's avatar
Soni
Occasional Contributor
8 years ago

copying files to a different project - importing files , merging name mapping

Hi

 

I have 2 projects in a project suite. I want to copy  files from one project to another. I found the documentation for Importing tests (Add > Existing item ) which does not create a copy of this test, it just adds a reference to the project.DO I have to merge the name mapping also after adding the keyword tests?

What are the complete steps I need to  follow so that I can add existing keyword tests from one project to another?

Do I have to merge the name mapping also after adding the keyword tests?

If the tests use local or project level variables are these merged too?

 

Is there a tutorial explaining this process ?

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Well, there are several considerations going on here.  As you noted, importing a test into another project creates a reference to the original.  This is actually by design and actually fairly common usage.  In fact, what we do here is, any tests that are "common" between projects we store in a completely separate folder in our source control called "Common\KeywordTests" and "Common\Scripts".  

     

    As for the namemapping, yes, you'll need to find some way of making the name mapping universal as well.  You can use the built in "Merge with" for name mapping.  I've had some success with that but, if you're name mapping tactics are "lazy", you could end up with a lot of duplicated objects.  What I've found works best is, just like was done with the keyword tests and scripts, create a "Common\NameMapping" folder and put a single NameMapping file in that folder that all my projects reference.  You won't need to "merge" anything in TestComplete (although, you'll need to do some merging on occasion in whatever source control you use).

     

    As for local or project level variables.  If the variable is part of the Keyword test or is declared locally in the script code unit, there's no need to "merge" that.  It is brought along with the file as a "common" piece.  Project level variables are a different story.  Since you are in a project suite and you want to continue to use the variable provided like they are on projects, there are Project Suite level variables.  Consider moving your "global" variables from the project level to the suite level.

     

    As for a tutorial - everyone's "needs" are different.  There are different tactics for different needs.  I don't think there is a specific "tutorial" on "Here's all the stuff you need to do when sharing a keyword test between projects".  Good idea, though, but, no, doesn't exist.  Basically, though, the rule of thumb is that if your test is using something that is in one project, you need to find some means of making it available to all the projects in which you are using the test.

    Hopefully what I've mentioned above helps you sort stuff out.

    • Soni's avatar
      Soni
      Occasional Contributor

      Thanks for you reply! 

      Here is what I did : imported a test from another project and merged the name mapping too. There were some conflicts in the merge and I have the _new items in the mapped and aliases. 

      1)When I run the imported test, it cannot find the objects. 

      2) If I point these objects to the newly merged objects (_new) - as the changes are saved to this test, it will not run when I run it from the original project.

       

      How do I fix the name mapping so that the  test can be run from both the projects?

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        What you need to do is resolve the conflicts in the merges... get everything down to 1 set of objects with a consistent naming so that, no matter what project you're in, it will work.  That's pretty much where your work load is right now since you're not using a shared name mapping file.

    • JennyH11's avatar
      JennyH11
      Frequent Contributor

      Hi Robert

       

      I'm really interested in following this at some point as I'd like to move a number of keyword test items (and associated files) to a new project.

       

      Following on from reading the below in your post, I would like to know how you reference a specific NameMapping file from a project?

       

      "What I've found works best is, just like was done with the keyword tests and scripts, create a "Common\NameMapping" folder and put a single NameMapping file in that folder that all my projects reference."

       

      Thanks,

      Jenny

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        In a project that doesn't already have a NameMapping file, right click on the project node in the project explorer, click Add -> Existing Item, browse to the desired NameMapping file and select it.