How to stop TestNG executioner when exception occures?

I have a web driver automation framework using TestNg.

I would like to do some check to see if all the services needed for my tests is running. If it is not running, then I would like the Test Execution to stop and let me know via a message that the services are not up.

My questions is a below

  1. What’s the best way to force TestNG  to stop execution when service is not running.?
  2. Capture the exception in console when executing programmatically?

Your help is very much needed and appreciated.

vjohnsonm Default Asked on June 17, 2015 in Selenium WebDriver.
Add Comment
3 Answer(s)

1. If I understand you correct, the best way to  stop test execution it’s fail it.(Assert.asertTrue(<some false condition>, “Description of fail”) for example.)
2. try{
<your code>}
catch(Exception e){
e.printStackTrace()}

victor Reviewer Answered on June 25, 2015.
Add Comment

If I am not mistaken, the above answer would just ,mark the Test as failed and continue with the next test in the Test suite.

I wanted the Test Suite to not run, if the check to see that the that all the necessary services are not running.

So in console, I should just see the message that –Services are not running. and Test should completely stop. I do not want my 200 test cases to be run at that time. I know, I can depending on a condition check –Skip the Test Cases.

But, I do not not want the test cases to be Skipped either. I want Test Suite Run to be completely Stopped.

vjohnsonm Default Answered on June 25, 2015.
Add Comment

oh, I see.
I’m no sure that it can be released on your code side.

Probably you can send some GET/POST request to your service, and check the answer.
If it is positive, run you test suite. All of it you can release with running service like Jenkins, TeamCity etc.

victor Reviewer Answered on June 26, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.