Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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?

share|improve this question
    
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 Oct 19 '12 at 23:49
    
Also see if this question is in the line of yours? -- stackoverflow.com/questions/8754615/… –  Suchit Parikh Oct 19 '12 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 changed –  MichaelF Oct 26 '12 at 11:55
add comment

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 :-)

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.