Forums Register Login

Is it possible to supress the exception with annotations ?

+Pie Number of slices to send: Send
Hello Ranchers
Can anybody please let me know whether it is possible to supress the exception that might occor in the method execution with the help of annotation. ? What I am looking for is



In the above method @SomeAnnotation should do the magic of supressing all the exceptions that might occour while method execution.
The typical use case is, while running the tests if any of the statement fails to pass , entire execution of the test gets halted. I dont want that to happen.
Any white paper. link will greatly be appriciated
Thanks in advance
Samir
+Pie Number of slices to send: Send
I know you can suppress warnings with @SuppressWarnings. I don't think it is possible to do what you want unless you start messing with java-byte-code manipulators (such as javassist).
But why not surround it with:
+Pie Number of slices to send: Send
If your test code can throw exceptions then you shouldn't be ignoring them--that should be part of the tests.
+Pie Number of slices to send: Send
Hello Wouter and David
Thanks a lot for the quick reply . I agree with Wouter that we can surround the the statement with try catch . But considering 10000 lines of code, it will be very difficult to manage the code. That is the reason I want to go for something else

David,
I do agree that if the exception is thrown , then it should be handled by the developer. But in case of selenium test suite, even if one test fails (i.e. exception thrown is not caught ) rest of the test cases dont run and execution process halts. I want to get rid of this so that complete test suit will run and a complete report with fail and pass test cases can be produce.
Please let me know your comments on the same
Thanks in advance
Samir

+Pie Number of slices to send: Send
There's no such magical annotation. You should check the documentation of your test suite to see if you can run all tests without halting.
+Pie Number of slices to send: Send
Yes...I do agree. There is no such annotation provided out of the box by JDK . But can we write one ? Can anybody please guide me on the same line ?
Thanks,
Samir
+Pie Number of slices to send: Send
Marking a method with an annotation doesn't do any magic either. You can a method with a custom annotation called @Burp, but it's not going to make it burp by itself. The piece of code using this method will have to check that the method is annotated, and make it burp.

The test suite software would need to interpret such an annotation. So if you made the test suite software, you can make changes so that any method marked with the annotation should be skipped when an exception occurs. So the big question is : Did you make the test suite software, or are you using a third party software ?
+Pie Number of slices to send: Send
What test suite are you using? If a single test fails because an exception, that test should fail--that test should not keep running.

The test suites I use (JUnit, TestNG) don't stop running *all* tests because a single one fails.
+Pie Number of slices to send: Send
Hello David,
We are trying to run Selenium test at our end. In case of JsUnit test we can specify the flag which will determine whether to halt the execution on test failure or not .Bu tin case of selenium tests, its not provided yet
+Pie Number of slices to send: Send
If you're running Selenium tests via JUnit, then that behavior is controlled via JUnit configuration--I'm still not sure what the actual issue is, because we're running Selenium tests and the test suite doesn't just stop if a single test throws an exception.
+Pie Number of slices to send: Send
I agree with David. we have also used selenium via junit and failure of one test case do not stop the execution of further tests. But it has happened once when test cases were not executed and we found it was due to out of memory on the selenium server. So make sure the exception you are getting is not something which halts the selenium server itself.
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4088 times.
Similar Threads
need exception
Error JSP - Tomcat
Mind Q Answer Issue..
Unreacheble Code
window.close()
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:25:02.