Scheduling automatic runs at nighttime

When working with a hefty backlog of automated tests, launching those may be long-winded and take hours. One of the effective methods to resolve this problem is automatic launch of the tests when there is no one at work, and tests are not in anyone's way. This could be nighttime, weekends, or holidays. In this recipe, we will consider automatic launch of the tests every night.

Getting ready

In order to learn how to launch the executable tests from the command line, read the Running tests from the command line recipe.

How to do it...

In order to schedule test run, we need to perform the following steps:

  1. Create the starttc.bat file with the following entrails:
    taskkill /f /t /im testcomplete.exe
    timeout /T 10
    set TCPATH=C:Program FilesSmartBearTestComplete 9Bin
    "%TCPATH%TestComplete.exe" Z:TestCompleteCookBookTestCompleteCookBook.pjs /run /project:Chapter4 /exit

    we will be launching this file by the schedule.

  2. Launch Windows Task Scheduler by going to Start | All Programs | Accessories | System Tools | Task Scheduler.
  3. In the Task Scheduler window, select Action | Create Basic Task...
    How to do it...
  4. In the appearing window, Create Basic Task Wizard, enter the name of the task (for example, TestComplete Tests), and click on the Next button.
  5. In the Task Trigger window, select the Daily option, and click on Next.
  6. In the next window, signify the date and time for the first launch (the date may be left at present, the time as 00:00:00), and then click on Next.
  7. In the Action window, select the Start a program option, and click on Next.
  8. Click on the Browse... button and select the created starttc.bat file.
  9. Click on Next.
  10. In the Summary window, check all the entered data is correct or not, and click on Finish.
  11. In the left-hand side part of the Task Scheduler window, select the Task Scheduler Library element.
  12. In the right-hand side part of the Task Scheduler window, locate the newly created task TestComplete Tests, and right-click thereon to further select the Run option.

If everything has been properly done, the tests will be automatically launched for execution.

This task will be launched every night.

How it works...

Since we cannot launch more than one copy of TestComplete, the first and foremost thing to do in the .bat file is closing the respective process thread with the help of the taskkill command, which is a part of Windows. This is done despite the possibility of TestComplete remaining open for some reason at the moment of the task's launch.

Further on, with the help of the standard timeout command, we await for 10 seconds. It is necessary to have all the resources duly released that are being utilized by TestComplete, or else upon successive launch we could run amuck with error messages. Depending on the speed of the computer, this parameter may be greater or lesser, nonetheless we recommend it be left at a greater value (for example, 30 seconds). Such an insignificant lag will have no impact on the timing of the test's execution, rather this parameter will not have to be customized each time against launches being transferred onto another computer.

Further more, with the help of the set command, we create a TCPATH variable, which will contain the pathway to the folder wherein TestComplete resides. This is optional, however the pathway can be signified fully in the following command, but then the command line could be long-drawn-out. In the last command, we launch the tests from the Chapter4 project up to execution. With the help of /exit parameter, we signify that, having completed all the tests, TestComplete should close down.

See also

Running tests from command line is explained in detail in the following recipe:

  • The Running tests from the command line recipe
..................Content has been hidden....................

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