From: Steve F. <sm...@us...> - 2003-11-18 23:12:56
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/functional/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv345/src/core/functional/test/mockobjects/dynamic Added Files: ErrorReportingTest.java Log Message: Added better error reporting. Shows invocation and invokables. --- NEW FILE: ErrorReportingTest.java --- /* * copyright mockobjects.com 04-Oct-2003 */ package functional.test.mockobjects.dynamic; import com.mockobjects.dynamic.C; import com.mockobjects.dynamic.DynamicMockError; import com.mockobjects.dynamic.Mock; import com.mockobjects.util.AssertMo; import com.mockobjects.util.TestCaseMo; public class ErrorReportingTest extends TestCaseMo { public ErrorReportingTest(String name) { super(name); } public interface OneMethod { void oneParam(int val); } public void testErrorMessageIncludesNameExpectationsAndInvocationDetails() { Mock mock = new Mock(OneMethod.class, "target mock"); mock.expectAndReturn("oneReturn", "wrong param", "a result"); mock.expect("twoParams", C.eq("one", "two")); try { ((OneMethod)mock.proxy()).oneParam(-1); } catch (DynamicMockError err) { String message = err.getMessage(); AssertMo.assertIncludes("Should have name", "target mock", message); AssertMo.assertIncludes("Should have type name", "OneMethod", message); AssertMo.assertIncludes("Should have method name", "oneParam", message); AssertMo.assertIncludes("Should have parameter value", "-1", message); AssertMo.assertIncludes("Should have expectation preamble", "in:", message); AssertMo.assertIncludes("Should have expected method name", "oneReturn", message); AssertMo.assertIncludes("Should have expected method param", "wrong param", message); AssertMo.assertIncludes("Should have expected method result", "a result", message); AssertMo.assertIncludes("Should have expected method name", "twoParams", message); AssertMo.assertIncludes("Should have expected method param", "one", message); AssertMo.assertIncludes("Should have expected method param", "two", message); AssertMo.assertIncludes("Should have expected method result", "void", message); } } } |