I have a java program that throws an exception with two different messages for two different scenarios, and I want the Junit test case to check equality for both of these messages. As an example -
public void amethod() {
if(scenario1 == true) {
throw new MySystemException("An error occured due to case 1 being incorrect.");
}
else if(scenario2 == true) {
throw new MySystemException("An error occured as case 2 could not be found");
}
}
Now JUnit for this will be something like <
public void testAMethod() {
assertEquals("Expected", "Actual");
}
, , Scenario1, junit , Scenario2 .
, - , Junit, test method , ?
- OR, , .
, .
UPDATE
, - .
, , , .
, , , . , ,
public void testAMethodScenario1() {
assertEquals("Expected Exception Message 1", "Actual");
}
public void testAMethodScenario2() {
assertEquals("Expected Exception Message 2", "Actual");
}
.