Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Exception in JUnit test (easy question)

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Thanked 0 Times in 0 Posts

    Default Exception in JUnit test (easy question)

    I have a question about a JUnit test case which I am building for a simple RPN calculator.

    Here is the test case, I basically want to test what happens when you increment MAX_VALUE

    public void testPlusExtreme() throws CalculatorException{
    Double result = fc.result();
    //Some JUnit assertion

    But what do I add to ensure that the Overflow exception is received?
    Is it try and catch?

    Thanks a lot!

  2. #2
    Join Date
    Oct 2011
    Thanked 2 Times in 2 Posts

    Default Re: Exception in JUnit test (easy question)

    I might do not understand your question. But from my experience, I never added any exception in Junit because Junit is only to test what your code (class) is okay. all possible exceptions need to be added in your code.

Similar Threads

  1. validate XMl by using XMLUnit and JUnit test?
    By beruska in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 16th, 2011, 08:20 AM
  2. Easy array question
    By surfbumb in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 3rd, 2011, 09:44 PM
  3. Quick easy Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 25th, 2011, 03:59 PM
  4. [SOLVED] Begginer Question please help ASAP! (Easy to Answer)
    By Bagzli in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2010, 10:00 PM
  5. JUnit test for ER
    By raphytaffy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 20th, 2010, 09:26 PM