Command Line Interfaces are often preferred by many users, as they provide a more concise and powerful means to control a system or application. Also the applications with command-line interfaces are often much easier to automate via scripting.
A command-line interface (CLI) is a means of interaction with a computer program where the user (or client) issues commands to a program in the form of successive lines of text (command lines).
Automating TestComplete becomes very easy via its Command-line interface. This is very simple and below are the ways to run it
TestComplete.exe file_name /run /project:project_name
file_name : Launches TestComplete and loads the specified project
/run (/r) – Commands TestComplete to execute tests provided by the project specified by the file_name argument.
/project (/p):project_name – Project_name is the name of the project. This will execute only those test items that are selected on the Test Items page. The unselected items are not run.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /r /p:SampleTest
TestComplete.exe file_name /run /project:project_name /projectitem:item_name
TestComplete will run test(s) provided by the specified project item. Project_name specifies the name of the project that holds the desired project item (use the same name as the name shown in the Project Explorer panel). Item_name is the name of the desired project item. only those project items that have the Run item in their context menu can be run in this case.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /r /p:SampleTest /pi:HelloWorld
Note : – Test items are those which are displayed on the Test Items page of the project editor. Project items are project elements that are shown in the Project Explorer panel.
TestComplete.exe file_name /run /project:project_name /test:test_name
TestComplete will run the specified test. This can be any element that TestComplete can execute: a keyword test, a script routine, a low-level procedure, a manual test, a network suite, and so on.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /r /p:SampleTest /t:"KeywordTests|Test1"
Test_name is the full name of the needed test. The full name of a test includes the test name, the name of the parent project item and, for scripts, the name of the unit, which are separated by the pipe character ( | ) and enclosed in quotation marks. For example, “KeywordTests|Test1”, “LLCollection1|LLP1” or “Script|Unit1|Main”.
TestComplete.exe file_name /run /project:project_name /unit:unit_name /routine:routine_name
TestComplete will run the specified script routine. Project_name specifies the name of the project to which the routine belongs. Unit_name specifies the name of the unit holding the desired routine. Routine_name is the name of the script routine to be called. The routine to be called must not use parameters or return any values. Project_name and unit_name should be the same as the project and unit names shown in the Project Explorer.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /r /p:SampleTest /u:Unit1 /rt:Test
No /project, /unit or /routine arguments specified. TestComplete will run the tests provided by the opened project suite.
/exit ( /e) – TestComplete will close after the project (or project suite) run is over, should be used with /run argument.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /r /e
This will execute all the projects that are enabled, waits until the execution is over and then TestComplete gets closed.
/SilentMode – If this argument is specified, TestComplete works in Silent mode, that is, it neither displays dialogs, nor informs you about errors or warnings.
TestComplete.exe "C:\TC\Example\SampleTest.pjs" /run /exit /SilentMode
/exportlog:File_name (or /el:File_name) – Exports the test run results to the .mht file specified by the File_name parameter.
/ForceConversion – If this argument is specified and TestComplete is running in Silent mode, TestComplete automatically converts projects created in earlier versions of the tool to the new format when they are opened.
/ns – Opens TestComplete without displaying the splash screen.