Running tests from the command line

One of the most important tasks in test automation is a possibility to launch tests from the command prompt (for example, in order to have tests run automatically at a preset time or embed launching tests to the system at application compilation). TestComplete supports a wide variety of parameters for usage of the command line prompt (for launching tests and some additional customizations). In this recipe, we will deal with two possibilities: launching a separate function and launching the test plan.

Getting ready

Create several functions with any contents (even empty functions will do, that do not execute any actions whatsoever) and add these functions to Test Items (this we have seen in the Creating a test plan for regular runs recipe).

How to do it...

In order to run tests from command line, we need to perform the following steps:

  1. First, let's launch all the project tests to be executed.
    1. Launch the interpreter of the command line (for example, click on the Start button, write cmd in the search box, and press Enter).
    2. Write the following command in the interpreters window:
      "C:Program FilesSmartBearTestComplete 9BinTestComplete.exe" z:TestCompleteCookBookTestCompleteCookBook.pjs /run /project:Chapter4
      

      Here, we have a full path to the signified executable TestComplete file.

      Tip

      Please pay attention to the double quotation marks, they are necessary since the file path contains spaces.

  2. Then goes the name to the project suite. Further on come the parameters:
    • The /run parameter tells TestComplete that test or set of tests has to be launched, and not simply open the IDE.
    • The /project parameter expresses namely what should be launched (in the given case, the whole of the project, that is, all the Test Items of the project). Via the semi-column, the name of the project is to be written down (in our case, this is Chapter4).
  3. Now, let's launch to execute a separate function. To do this, we need to run the following command from a command line:
    "C:Program FilesSmartBearTestComplete 9BinTestComplete.exe" "z:TestCompleteCookBookTestCompleteCookBook.pjs" /run /project:Chapter4 /Unit:Unit1 /routine:testDemoTestItems2
    
  4. In this example, apart from the already known parameters, two more have been added:
    • /Unit: This signifies the unit in which the function for the launch is located
    • /routine: This signifies the name of the specific function that should be launched

      Tip

      Pay attention to the name of the unit being signified without the extension!

How it works...

The first method of launching allows the launch of all the enabled tests from the Test Items list. The second method allows to launch a single function. Certainly, we can create just a single function that nests calls of several functions within it, thus covering the whole of the testing plan. Nonetheless, in this case, contingent upon TestComplete getting accidentally hung-up, the possibility of losing entire log entries is much likelier, since Test Items are not used. At the point of using Test Items, the contents of the TestComplete memory, related to the logs, is committed to HDD upon completion of each of the tests.

Another inconvenience lies in the fact that we would have to comment all of the function calls of the corresponding functions to disable specific tests in the second case. Therefore, in the event of using Test Items, it will be sufficient to uncheck the corresponding Test Items.

There's more...

In TestComplete, there is a variety of additional parameters, allowing us in one way or another to influence the tests launching procedure: disabling the splash screen, silent mode (in which tests execution will not be stopped even in the event of a critical error), exiting upon completion of scripts processing (to continue batch-file execution), exiting codes (useful at the point of integration with the systems of continuous integration), and so on.

For running tests from command line you can use a special command-line tool called TestExecute. It uses the same parameters as TestComplete, but doesn't have IDE and can be used only for running tests.

Note

If you have TestComplete Enterprise, then you also have one license for TestExecute. Additionally, TestExecute licenses can be purchased separately on the SmartBear website at http://smartbear.com/products/qa-tools/automated-testing-tools/automated-testing-add-ons/test-execute.

See also

Running scripts from command line is usually used for creating regular runs:

  • The Creating test plan for regular runs recipe

We can also pass additional parameters to script from command line:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.249.252