Ask a Question

Referencing Keyword Test from one project into another project

abhibajare
New Contributor

Referencing Keyword Test from one project into another project

Hi,

I have created different projects to test my application using Test Complete. The project suite hierarchy is as shown below.



ProjectSuite

ProjectCommon

Advanced

Script

CommonScript (This updates project level variable)

Keyword Test

SaveFile

OpenFile



ProjectTest

Advanced

Script

CommonScript (Referenced from ProjectCommon using "Add -> Existing Item...")

Keyword Test

SaveFile (Referenced from ProjectCommon using "Add -> Existing Item...")

OpenFile (Referenced from ProjectCommon using "Add -> Existing Item...")

SaveOpen (Local test which calls CommonScript, SaveFile and OpenFile)







Problem:

1) When I run CommonScript from ProjectCommon, it runs fine. But when I try to run same CommonScript from ProjectTest (in SaveOpen test), it searches for project level variable in ProjectTest. Actually, I intend to update ProjectCommon variables using CommonScript.



2) When I call SaveFile from ProjectTest, I expect SaveFile to use Namemapping file from ProjectCommon where it is created\exists. But this doesn't work unless I merge ProjectCommon namemapping file into ProjectTest namemapping file.



I expected it to work same as how C# project works when we reference 1 project into another.



Thanks!
Regards,
Abhishek
3 REPLIES 3
HKosova
Moderator

RE: Referencing Keyword Test from one project into another project

Hi Abhishek,



1) When I run CommonScript from ProjectCommon, it runs fine. But when I try to run same CommonScript from ProjectTest (in SaveOpen test), it searches for project level variable in ProjectTest. Actually, I intend to update ProjectCommon variables using CommonScript.


A project variable is available only within the scope of the project in which it's defined.

When you run CommonScript from ProjectTest, the script is executed in the scope of ProjectTest, not ProjectCommon. That's why TestComplete looks for the variable in ProjectTest.



In order for a variable to be available in different test projects, you need to define it on the project suite level instead of the project level.





2) When I call SaveFile from ProjectTest, I expect SaveFile to use Namemapping file from ProjectCommon where it is created\exists. But this doesn't work unless I merge ProjectCommon namemapping file into ProjectTest namemapping file.


Like in the previous case, tests use NameMapping of the project in whose scope the tests are run. If you run a test inside the ProjectCommon project, it uses ProjectCommon's NameMapping; if you run the test inside ProjectTest, it will use ProjectTests's Name Mapping.



For your scenario, the preferred solution is to create a single NameMapping file for both projects and share it among the projects, like you share common scripts and keyword tests.



We have a feature request to make it possible to use multiple Name Mapping files in the same project, and I've increased its rating. So thanks for the feedback!





I expected it to work same as how C# project works when we reference 1 project into another.


TestComplete and Visual Studio are different products used for different purposes, so their behavior cannot be exactly the same.

Please feel free to ask any questions if you need more information or assistance. We'll be happy to help you!

Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
abhibajare
New Contributor

RE: Referencing Keyword Test from one project into another project

Thanks Helen for your reply!



Then, I will create only 1 project so that I call required Scripts or Keyword Test without bothering about which variables I am using inside those. May be I will use "Folder" to group similar tasks.



Now, another question comes up that when and why should we create multi-project project-suite?
Regards,
Abhishek

RE: Referencing Keyword Test from one project into another project

Hi Abhishek,



Yes, using a single project is also an option in your case.



To answer the other question as to when you might want to use multi-project suites, here're some thoughts:


* Modularity, e.g. using different projects for different components of the tested application, or different tested applications.


* Being able to view and work with multiple projects at the same time. (If you have one project per suite, you'll need to close the current project/suite before opening another one).


* Share some data between the projects using project suite variables.


* Switching to another scripting language for new tests.

Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: