I am working one a school program that requires me to test a custom defined exceptions.
There are 5 Calculator.java files and my job is to add more cases and find which runs perfectly right.
However when I try to use Expected exception test to test the excetion, it seems that the as long as the first case works well, the program will automatically be thrown and stop there. The other cases behind //TODO will not run at all.
/**
* The calculate method have to return the Grade based on :
*
* "lab", "ass1" and "ass2" marks are between 0 and 10 (inclusive).
* + "final" is between 0 and 100 (inclusive).
*
* If any of these components are not within the expected range
* then an OutOfRangeException is thrown.
*
*/
//Here is the interface of MarkCalculator
public interface Calculator {
Grade calculate(int lab, int ass1, int ass2,
int final, boolean attended) throws OutOfRangeException;
}
Can someone please tell me how to prevent this from happening, thanks
@Test(expected = OutOfRangeException.class)
public void testException() throws OutOfRangeException {
calculator.calculateMark(-1, 0, 0, 0, true);
//TODO: write more test cases if you need
calculator.calculateMark(100 , 0 , 0 , 0 , true);
calculator.calculateMark(0 , 11 , 0 , 0 , true)
}