No Code Coverage when using Rhino.Mocks 3.6

21 views
Skip to first unread message

Benjamin

unread,
Sep 8, 2010, 3:14:01 AM9/8/10
to Rhino.Mocks
Why is there no code coverage when using Rhino.Mocks 3.6 in VS 2008
even though the testrunconfig enabled the code coverage already for
the target assemblies?

Tim Barcz

unread,
Sep 8, 2010, 8:06:26 AM9/8/10
to rhino...@googlegroups.com, Rhino.Mocks
Ben,

I don't understand what you mean.. please explain and/or provide a screenshot.

Tim

> --
> You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
> To post to this group, send email to rhino...@googlegroups.com.
> To unsubscribe from this group, send email to rhinomocks+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
>

Stephen Bohlen

unread,
Sep 8, 2010, 8:41:51 AM9/8/10
to rhino...@googlegroups.com
Do you mean "code coverage for the Rhino.Mocks codebase" or do you mean "code coverage for your own code-under-test when writing tests with Rhino.Mocks" ?  And by "no code coverage" do you mean you're having problems getting the VS2008 Code coverage report or you get the report but it shows zero coverage?

One thing to pay attention to is that you will (typically) see very low (if even non-zero) code-coverage for classes that you are MOCKING because (of course) those classes aren't actually in play during your tests (e.g., if they are mocked, their code isn't actually being tested and so their coverage will typically be zero).

But the classes not mocked but interacting with the mocks should show non-zero coverage numbers.  Rhino.Mocks shouldn't in any way interfere with the VS2008 code coverage tools generating their reports.  Can you try to write a test in a completely new project/solution to ensure that you are able to get  a code coverage report out of VS2008 when Rhino.Mocks isn't involved in the test-run?

Steve Bohlen
sbo...@gmail.com
http://blog.unhandled-exceptions.com
http://twitter.com/sbohlen

Benjie Fallar III

unread,
Sep 8, 2010, 10:28:20 AM9/8/10
to rhino...@googlegroups.com
Yes, my actual classes does not report code coverage. So using Rhino.Mocks really does not generate code coverage in VS 2008 because it's "mocking" the interfaces. What do you mean by "but the classes not mocked but interacting with the mocks should show non-zero code coverage"? But my normal classes using standard unit test project generates code coverage.

Regards,

 Benjamin P Fallar III
http://twitter.com/bfallar3


Tim Barcz

unread,
Sep 8, 2010, 10:32:02 AM9/8/10
to rhino...@googlegroups.com
If a class is not mocked, it will be called directly (not intercepted).  If it is called and not intercepted, then code coverage tools would see that it was executed and report a "non-zero" code coverage - simply meaning your code was executed.
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

Reply all
Reply to author
Forward
0 new messages