Obviously my question is not clear.
I have many unit tests and all methods are throwing same exception with different error message. "SomeException" is exception I must catch and read error message from it.
What I want to achive is to write one method which will be common to all unit tests and where I could print error message.
Now unit tests looks like this
public void test_something()
{
try
{
assertTrue(bw.doSomething("test"));
}
catch (SomeException e)
{
fail("exception = " + e.getReason());
}
}
public void test_something1()
{
IBroadworks bw = getSomehting1();
try
{
assertTrue(bw.doSomething1("test1"));
}
catch (SomeException e)
{
fail("exception = " + e.getReason());
}
}
...
So below code is repeating in all unit tests and that is not ok.
...
try{
assertTrue(condition);
}
catch (SomeException e)
{
fail("exception = " + e.getReason());
}
...