A test project contains tests of different types: scripts, keyword tests, low-level procedures and so on. Each test has a name. For script routines this is the routine’s name, for keyword tests, low-level procedures and other types of tests this is the name of the appropriate project element in the Project Explorer panel. You can run tests as test items, or you can run them from other tests. This topic provide detailed information about this.
Running a Test as a Test Item
-
Select your project in the Project Explorer panel and then select View | Organize Tests from the TestComplete main menu. This will open the Test Items page of the project editor.
-
Click New Item to add a new test item to the project.
-
Click the ellipsis button within the Test cell of the new test item and choose the test to be run from the resulting Select Test dialog.
Now the test will be run when you run the project.
Running Tests From Keyword Tests
From a keyword test, you can run script routines, low-level procedures and even other keyword tests. To do this:
-
Open your keyword test for editing.
-
Place the cursor somewhere within the Test Steps page in the Keyword Test editor and select Run Keyword Test from the context menu.
-
Add the Run Test, Run Script Routine or Run Keyword Test operation to the test.
TestComplete will display the Operation Parameters dialog where you can specify the name of the desired test and the test’s parameters (if any).
Now the specified test will be run when you run your keyword test.
Running Tests From Scripts
You can run tests from scripts. The way you do this depends on the test type.
-
Each script is a procedure written in VBScript, JavaScript, JScript, Python, DelphiScript, C++Script or C#Script. You can run this procedure from another script simply by calling it.
JavaScript, JScript
function TestRoutine1()
{
...
TestRoutine2(Param1, Param2);
...
}Python
def TestRoutine1(): ... TestRoutine2(Param1, Param2) ...
VBScript
Sub TestRoutine1
...
Call TestRoutine2(Param1, Param2)
...
End SubDelphiScript
procedure TestRoutine1;
begin
...
TestRoutine2(Param1, Param2);
...
end;C++Script, C#Script
function TestRoutine1()
{
...
TestRoutine2(Param1, Param2);
...
}You can also call routines defined in another script unit or project. See Calling Routines and Variables Declared in Another Unit from GUI and Calling Routines Declared in Another Project for more information.
-
To run other tests, you use special program objects that provide a scripting interface to these tests. These objects contain specific methods that run the test, for instance:
-
To run a keyword test, use the
KeywordTests.KeywordTestName.Run
method. -
To run a low-level procedure, use the
LLCollection.LLProcedure.Execute
method. -
To run a distributed test, use the
NetSuite.Run
method. -
And so on.
For detailed information on running tests from scripts, follow these links:
-