Forum Discussion
nmrao
Champion Level 3
Can you please show the sample listener code snippet which throws error and still continue?
RBlack
8 years agoOccasional Contributor
Sure. Here's some TestSuiteRunListener.beforeRun code that throws an exception:
throw new Exception('boom!')
The project still runs the test even when that exception is thrown. An exception in a project-level event handler means that setup failed, in which case the tests are doomed. In a production environment involving hundreds or thousands of tests, a lot of lab time can be wasted running tests that shouldn't have run and human time wasted diagnosing failures actually caused by a failure in project setup.
See attached standalone project created with 1.7.0, which demonstrates the problem.
Is there an option to halt test execution if exceptions occur in an event handler?
Rob