Forum Discussion
But then that linked Keyword Tests runs 'directly' in Feature One. I would also need to a) merge the name mapping, b) add existing to any keyword tests that 'start' and 'stop' reference and c) add existing any scripts that 'start' and 'stop' reference. Before long, I'll have 'added existing' to everything in Baseline into FeatureOne?!
I was expecting an answer along the lines of: create a script with a test 'Foo', add 'USEUNIT Baseline', and then call anything in 'Baseline' from within 'Foo'. That way I don't need to 'add existing' so pervasively.
Have you tried this?
http://support.smartbear.com/viewarticle/56538
Running Keyword Tests From Other Keyword Tests
To add a keyword test from another keyword test, use the Run Keyword Test operation. After you commanded TestComplete to add the operation to your test, TestComplete will display the dialogs, in which you can choose the test to be run and specify the parameters of this test (if it uses them).
Now when you run the “parent” keyword test, it will execute the inserted test. The result of the inserted test will become the result of the Run Keyword Test operation.
Note that a keyword test can run itself. In this case, we say that the test is run recursively. The recursion may be hidden. For instance, you may have a KeywordTest1 that runs the test KeywordTest2 and KeywordTest2, in its turn, runs KeywordTest1. Or even more complex: KeywordTest1 executes a code snippet that runs KeywordTest2, which runs a script routine, which, in its turn, runs KeywordTest1.
Recursive execution of tests may cause the stack overflow error. To avoid this, you should plan the execution sequence of tests carefully and use the If... Then operation to allow or forbid the recursive runs. In the simplest case, you can make the Run Keyword Test operation a child of the If... Then operation and use this If... Then operation to control whether the child Run Keyword Test operation should be executed or not.
- GoZoner11 years agoNew Contributor
Yes, I use that all the time for Keyword Tests defined in the same project.
But, if I define a test 'Bar' in FeatureOne then
a) I can't add a keyword test operation to 'Bar' that directly references 'Baseline - Start'
b) if I 'add existing' 'Baseline - Start' to FeatureOne, then I can include the 'start' reference in 'Bar' but 'Bar' doesn't run - because of name-mapping specifically.
For case 'b', I expected 'Baseline - Start' to run in the environment that 'Baseline - Start' was defined in (which is 'Baseline'); not the environment where 'Baseline - Start' is invoked (which is 'FeatureOne).' That is, 'Baseline - Start' is not behaving like a proper subroutine.
- Marsha_R11 years ago
Champion Level 3
Well, keyword tests aren't exactly equivalent to scripts, so you won't see all the features there that you might in a scripting language, e.g. subroutines.
If what you are expecting is for keyword test projects to be able to access each others tests and artifacts directly across project boundaries, I don't believe there's a way to do that, especially with the name mapping.
Another way into what you want might be to rewrite the tests that you want to share so they are not dependent on the name mapping. Then "Use Existing" would be simple.