Forum Discussion
You'll need to add 'Start' and 'Stop" to FeatureOne. Go into FeatureOne and right-click and choose Add Existing. Navigate to 'Start' and 'Stop' wherever they are stored for Baseline. Now the tests will be visible in FeatureOne, with an arrow next to them, indicating that this is pointing to a test outside the current project. You'll be able to reference those added tests just like any other test in the project.
- GoZoner11 years agoNew Contributor
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.
- Marsha_R11 years ago
Champion Level 3
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.