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
Code :
@Test
public void testPlusExtreme() throws CalculatorException{
fc.enter(Double.MAX_VALUE);
fc.enter(1.0);
fc.plus();
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!
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.