Passing Tests and Moq

6 views
Skip to first unread message

Darren Cauthon

unread,
Mar 22, 2010, 2:24:10 PM3/22/10
to MVC Turbine
I hope this is fine, but recently I took the initiative to hop into
the tests and try to work out the few ignores or fails that we had
(I'm a "stop the presses, the tests are failing!" type of developer).
In the MvcTurbine.Web.Tests project, there was a pesky error where the
Rhino Mocks returned the following error when trying to mock
IRotorContext:

"This action is invalid when the mock object is in verified state."

I think this issue affected 7 or 8 tests, and the error would only
occur when the tests were run as a set instead of individually. I
tried a couple things with TestFixtureBase and googling the matter,
but I couldn't get a working solution. So.... I added Moq to the
solution and replaced the Rhino Record/Playback setup on the failing
tests with the Moq equivalent. Pretty small change, it got past
whatever IL generation error was happening, and the tests are green
again.

The changes are at: http://github.com/darrencauthon/mvcturbine/commit/ab56705c161655ea4116d8ee00f8aa13ec37f98e

I hate adding a new library just to resolve an issue like this, but I
also hate failing tests. Does anybody have another way around this
issue?

Javier Lozano

unread,
Mar 22, 2010, 2:36:29 PM3/22/10
to MVC Turbine
I'm to blame for those ignores :), so thank you for fixing them. As
for adding Moq to the project, I'm all for it. I've had the same pain
points with RhinoMocks (as you stated the IL generation issue) but
never took it a step further due to lack of time (lame, I know.).

I've never played with Moq (again, lack of time) but always wanted to,
so it's a good change, IMO. Anything that makes our life easier and
get us better results, I'm all for.

Thanks for doing this!

On Mar 22, 1:24 pm, Darren Cauthon <darrencaut...@gmail.com> wrote:
> I hope this is fine, but recently I took the initiative to hop into
> the tests and try to work out the few ignores or fails that we had
> (I'm a "stop the presses, the tests are failing!" type of developer).
> In the MvcTurbine.Web.Tests project, there was a pesky error where the
> Rhino Mocks returned the following error when trying to mock
> IRotorContext:
>
> "This action is invalid when the mock object is in verified state."
>
> I think this issue affected 7 or 8 tests, and the error would only
> occur when the tests were run as a set instead of individually.  I
> tried a couple things with TestFixtureBase and googling the matter,
> but I couldn't get a working solution.  So.... I added Moq to the
> solution and replaced the Rhino Record/Playback setup on the failing
> tests with the Moq equivalent.  Pretty small change, it got past
> whatever IL generation error was happening, and the tests are green
> again.
>

> The changes are at:  http://github.com/darrencauthon/mvcturbine/commit/ab56705c161655ea411...

Darren Cauthon

unread,
Mar 22, 2010, 9:10:34 PM3/22/10
to mvctu...@googlegroups.com

Ok, great, I'll put a push request for the changes tonight.

I use Moq at home and work, and I like it a lot.  It took a while to get used to all the lambdas and to be able to keep the tests clean and readable, but no worse than the record/replay stuff with some of the others.  Pair Moq with an automocking container and you can have some pretty nice-looking unit tests.  :)

Darren

On Mar 22, 2010 1:36 PM, "Javier Lozano" <jglo...@gmail.com> wrote:

I'm to blame for those ignores :), so thank you for fixing them. As
for adding Moq to the project, I'm all for it. I've had the same pain
points with RhinoMocks (as you stated the IL generation issue) but
never took it a step further due to lack of time (lame, I know.).

I've never played with Moq (again, lack of time) but always wanted to,
so it's a good change, IMO. Anything that makes our life easier and
get us better results, I'm all for.

Thanks for doing this!


On Mar 22, 1:24 pm, Darren Cauthon <darrencaut...@gmail.com> wrote:

> I hope this is fine, but rece...

>
> I hate adding a new library just to resolve an issue like this, but I

> also hate failing tests....

Reply all
Reply to author
Forward
0 new messages