Terminating a tested application

Sometimes it becomes necessary to quickly terminate an application (for example, if we don't care about saving application results or the application stopped responding).

In this recipe we will learn how to forcibly close the application using a script.

Getting ready

Add the Notepad application to TestedApps.

How to do it...

In order to terminate a tested application we need to perform the following steps:

  1. Create and launch the following function:
    function testRunApps()
    {
      TestedApps.notepad.Run();
      TestedApps.notepad.Terminate();
    }
  2. In the result of the function call, the Notepad application will be launched and then closed.

How it works...

The Terminate method will forcibly kill the process of the application, without giving it a possibility to perform standard actions that are executable in the normal termination mode (for example, when a user presses the termination button to close the program). This action is analogous to terminating the process thread in the Task Manager.

This is why we should use the Terminate method only when we are sure that it will not lead to data loss or application intactness.

Another reason to apply the Terminate method is validation of the tested application's behavior in case of emergency shutdown (for example, will it notify us of its shutdown upon the next startup, will it restore the files that were being edited on the verge of the termination, and so on).

Usage of this method for normal termination of the program is not recommended.

See also

  • If you need to terminate all instances of the application, the Killing several instances of a tested application recipe will help you
  • The better way of closing applications under test is explained in the Closing a tested application recipe
..................Content has been hidden....................

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