Skip to content
Snippets Groups Projects
Commit cbe28679 authored by kaloyane's avatar kaloyane
Browse files

minor: verify mock expectations only when the test has not failed

SVN: 20872
parent 16eed21e
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ import java.lang.reflect.Method; ...@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import org.jmock.Expectations; import org.jmock.Expectations;
import org.jmock.Mockery; import org.jmock.Mockery;
import org.testng.AssertJUnit; import org.testng.AssertJUnit;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
...@@ -195,15 +196,19 @@ public abstract class AbstractBOTest extends AssertJUnit ...@@ -195,15 +196,19 @@ public abstract class AbstractBOTest extends AssertJUnit
} }
@AfterMethod @AfterMethod
public void afterMethod(Method m) public void afterMethod(ITestResult result, Method m)
{ {
try // only run assertions if has not failed
if (result.isSuccess())
{ {
context.assertIsSatisfied(); try
} catch (Throwable t) {
{ context.assertIsSatisfied();
// assert expectations were met, including the name of the failed method } catch (Throwable t)
throw new Error(m.getName() + "() : ", t); {
// assert expectations were met, including the name of the failed method
throw new Error(m.getName() + "() : ", t);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment