i have created a framework where all the WebDriver API resides and in other project I am just calling those test cases I have created but the problem is that if anything goes wrong in the test case I would like to capture the error but instead currently I am just getting output failed
so my question is what is the best way of capturing error messages?
-
Just to be clear, do you want to catch exceptions thrown by WebDriver OR are you looking to handle your test failures gracefully?Suchit Parikh– Suchit Parikh2012年10月19日 23:49:28 +00:00Commented Oct 19, 2012 at 23:49
-
Also see if this question is in the line of yours? -- stackoverflow.com/questions/8754615/…Suchit Parikh– Suchit Parikh2012年10月19日 23:50:34 +00:00Commented Oct 19, 2012 at 23:50
-
Do you use Assertons at all? I do this alot in my test cases especially for debugging when writing them and often leave them in place for use later in case I get unexplained errors later on then I just uncomment, build and run the test to see what has changedMichaelF– MichaelF2012年10月26日 11:55:59 +00:00Commented Oct 26, 2012 at 11:55
1 Answer 1
Depending on the implementation of your "other project" I would suggest that;
- Change the external project to throw exceptions in the event of failure
- Include a helpful error message, and some context about the current state of the method
- Implement a post-test screenshot capture
- We've implemented a JUnit Rule which extends TestWatchMan that runs after a test completes (for any case) and captures a screenshot from the remote server (base64 encoded png) and stores it with a filename like : ERROR-com.example.package.ClassName-myTestMethod.png which is kept by Jenkins for later review
If you want control in a programatic manner, go with the first option, if its for context of a failure, use the second.
Preferably, use both :-)