Forum Discussion

GoZoner's avatar
GoZoner
New Contributor
11 years ago

Accessing Items in an 'Existing Project'

I have an existing TC Project ("Baseline") that includes keyword tests called 'Start' and 'Stop'.  I have another TC Project ("FeatureOne") that is part of a Project Suite; that Project Suite has an 'existing project' link to 'Baseline".  From a "FeatureOne" keyword test how do I invoke the "Baseline" Start test?

 

I've tried a number of things; but, I won't bother you with my failures.  I'm hoping to get a step-by-step description - can't imagine it is longer than 3-5 statements.

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Icon for Champion Level 3 rankChampion Level 3

    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.

     

     

    test.png

    • GoZoner's avatar
      GoZoner
      New 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_R's avatar
        Marsha_R
        Icon for Champion Level 3 rankChampion 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.