This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Testing and the fly likes Multiple Expected Exceptions in JUNIT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Multiple Expected Exceptions in JUNIT" Watch "Multiple Expected Exceptions in JUNIT" New topic
Author

Multiple Expected Exceptions in JUNIT

Ayan Biswas
Ranch Hand

Joined: Jul 10, 2010
Posts: 104
I know that if I use annotation asthen i am expecting a null pointer exception from the code but what if I expect multiple exceptions ,how can I write it?


AyanBiswas
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 122
I don't like to answer a question with a question, but if doing a unit test I would think you should only expect one exception. Is it possible your test needs to be split up one per exception such that you can confirm under the expected conditions (or unexpected if you will as these are exceptions) that the exception occurs?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple Expected Exceptions in JUNIT