Mock objects not compile aware

28 02 2007

When I use mock objects in this case NMock, I would really like to have compile time check that passing the paramters to the expectation as strings

Example

Expect.Once.On(dbHelper).Method(”GetRequestsForUser”)
.With(userID).Will(Return.Value(requests));

In case in point above I am expecting that when i call the helper in that a method called GetRequestsForUser with userId
will return something

The problem is the mock framework is quite dumb until invoked.

When i want to refactor by adding a new parameter to the method GetRequestsForUser, the compiler has no clue that i have to change the test above.

Does anyone know the intent behind choosing such a design for the mock framework. Is there something more smart out there.

Update: Found out from one of my friends about Rhino mock. A typed mock framework. I haven’t used it yet, but plan to try it out soon.


Actions

Information

Leave a comment

You must be logged in to post a comment