How do I set up a TestCaseExit/TestCaseEnter function to over-ride the default function used by SilkTest?
This is an example of how to create and implement your own TestCaseEnter and/or TestCaseExit function, in order to over-ride the Default enter and exit functions used by SilkTest. Files with the working example are available to download at the bottom of this resolution.
- Write your TestCaseExit function into your include file. (Note: All TestCaseExit functions must include the first 3 lines as shown below)
A TestCaseEnter function would look like this:
- Create a script file and testcases, which you wish to use the TestCaseExit/TestCaseEnter function(s). Every testcase in this script file will use the function(s), so make sure that it is ok to do this for each of the testcases in your script.
- Make sure that your script is referencing the include file where your function(s) resides, if not, then it will have no access to your function and will instead use the default. You will not be able to over-ride the default unless you reference the file where your function(s) is located. This can be done either in the Options/Runtime "Use Files" section or by adding a "Use" statement into your script (as seen below).
- Now you are ready to run the script. As long as the script is referencing the include file, SilkTest will execute the TestCaseEnter function before running the testcase, and when your testcase has finished executing, SilkTest will automatically call your TestCaseExit function and execute. In the example below, the testcase has referenced both user-defined functions. As you can see, the file shows that the TestCaseEnter was executed first, followed by the script and the TestCaseExit was the last to be executed.
Working Example of process explained above: