QTP: Is it possible to create a function that will be executed before / after each test run

Is it possible to create a function that will be executed before / after the start of each test? Maybe something like this .

For example, this is necessary for

  • return to clean db before each test
  • clear application cache or registry settings after each test

Of course, you can create 2 functions and call them explicitly in the first and last line of each script. However, it would be advisable to define them once in one place so that they are automatically called for each test.

+3
source share
2 answers

. / QTP . . , , .

.

  • , Init/Done, , . , , , , . .

  • , /, , . VBScript , . VBScript OOP.

  • "" script, . / , " " . /, , script.

+3

, . .qfl lib :

private autoInitiatorTerminator : Set autoInitiatorTerminator = new cls_autoInitiatorTerminator

class cls_autoInitiatorTerminator

   private sub class_initialize
       ' put here your initiation code
   end sub

   private sub class_terminate
       ' put here your termination code
   end sub
end class

Add-And-Forget (tm): , .

+3

Source: https://habr.com/ru/post/1789268/


All Articles