• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Expected Exceptions in JUNIT

 
Ayan Biswas
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Brian Burress
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic