I have the following code segment to test inside if block
if("anyString".equals("anyString")){
//body
}
How can I test above using easy mock as follows
lets take Chair as base class and getName() method which returns it name
expect(chair.getName()..eq("string")).andReturn(true);
it's throw an InvocationTargetException
Any Help Appreciated
These are two strings. There is no point in mocking a String. Your expect
currently doesn't make sense Please see the EasyMock documentation.
If we say that chair
is a mock, and you want getName()
to return string
, it would be expect(chair.getName()).andReturn("string");
I don't think it is relevant to your question but not that equals
can't be mocked. It's a special method used by EasyMock internally. equals
, toString
and hashCode
can't be mocked.