Forum Discussion
HKosova
13 years agoSmartBear Alumni (Retired)
Hi Abhishek,
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.
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!
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!
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!
Related Content
Recent Discussions
- 2 days ago
- 2 days ago
- 6 days ago