• Post Reply Bookmark Topic Watch Topic
  • New Topic

JUnit Tests  RSS feed

 
Ranch Hand
Posts: 206
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a method inside of a try block and there are catch blocks that can catch JMSExceptions, HL7Exceptions, and a catch all exception. I have a JUnit test that calls this method. How can I set up my JUnit test so that a JMSException will be thrown?
 
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should mock whatever it is that you're calling from the method that you're testing, so that it throws an exception. You can use a mocking framework such as JMockit.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!