I've got the following test which I have put a try catch around so it fails if actual value does not equal expected value:
try{
Assert.assertEquals(ExpectedCount, ActualCount);
}catch (Throwable t){
System.out.println ("Actual value is not equal to expected value");
}
Whenever I run this test it passes. However if expected=actual no message is printed, which is correct. If they are not equal then the message i printed. So the test logic is valid.
However the Juint test still passes.
I have been trying the incorporate the following but cannot get it to work:
(Added this at public level in the class of the test)
@Rule
Public ErrorCollected errCollector = new ErrorCollector();
Added:
errCollector.addError(t);
Under
System.out.println ("Actual value is not equal to expected value");
I am getting the error back "Rule cannot be resolved to a type
" It does not give me any option to import.
I've been trying to find out how use the @Rule
method to make the test to fail, but cannot figure it out.