How to get the script return code
- 6 years ago
OK, I set up a quick scenario to demonstrate the OnStartTest and OnStopTest event handlers.
First, I set up 5 tests. All these do is just write a quick message to the log.
Next, I set up the Events item in my project. If it's not already there, you can right click on your project node and select "Add Item -> New Item" to add the Events item.
Double click on the OnStartTest event to add a handler. You can create a new unit or use an existing unit. When you have the unit selected, it will link the event to the handler script. You can see in the picture that, when this is done, the event has an electric bolt icon next to it.
When you add a handler, it creates a function in your chosen script language that is empty. I created two handlers, one for OnStartTest and one for OnStopTest. My handlers don't do much of anything except log that I'm starting a test and stopping a test. Here's the code.
function GeneralEvents_OnStartTest(Sender){ Log.Message('Test started'); } function GeneralEvents_OnStopTest(Sender){ Log.Message('Test Stopped'); }
So... I have the script tests set up to run as test items, I have my events added to my project, I have my event handlers created. Now, when I run my project, this is what I get in my log.
Each test item has it's own node in the log and each test item reflects the OnStartTest and OnStopTest handlers with the test execution running in the middle.
Does this help you understand better what we're talking about?