chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I am wondering if TypeMock can work with Clover.Net code coverage tool. I do not see the option of linking TypeMock with Clover.Net.
asked by jnapier (9.6k points)

12 Answers

0 votes
I am wondering if TypeMock can work with Clover.Net code coverage tool.


Hi,
There should be no problem running TypeMock with Clover.Net.
Just run the tests after Clover Instruments your code.
If you try it and failed please tell me
answered by scott (32k points)
0 votes
Scott, I am having issues running my unit tests with clover.net and TypeMock. All of my tests succeed when not instrumented. When I run the tests on the instrumented code, all of the tests that use TypeMock fail. It appears to be a problem when using a MockObject. Here is some code that fails.

MockObject procedureMock = MockManager.MockObject(typeof(Procedure));

Procedure testProcedure = procedureMock.Object as Procedure;

MockObject processMock = MockManager.MockObject(typeof(Process));

testProcedure.Process = processMock.Object as Process;


The last statement is just a simple setter and fails with this error

System.NullReferenceException : Object reference not set to an instance of an object.

I have stepped through the code with the debugger and the error occurs before any code in the setter is even executed. Please let me know if you need more information so that we can resolve this problem with clover.net.
answered by jnapier (9.6k points)
0 votes
Hi,
Clover.NET uses the static constructor (.cctor) of the class to initialize some internal field that NCover uses to gather information.

Your code mocks Procedure static constructor and thus Clover.NET throws the Exception.
In order to bypass this make sure that you let the static constructors run (unmocked) as follows:
MockObject procedureMock = MockManager.MockObject(typeof(Procedure,Constructor.StaticNotMocked)); 


:idea: I will add a requirement to support Clover.NET linkage when static constuctors are mocked
answered by scott (32k points)
0 votes
I wasn't referring to NCover. Did you mean clover.net?
answered by jnapier (9.6k points)
0 votes
Woops typo... I fixed it in the original post
answered by scott (32k points)
0 votes
Ok thanks. So I have to change all of my code to the example you have provided above? Is this just for MockObjects, or do I need to do it for Mocks as well?

What if I need to mock the static constructor?
answered by jnapier (9.6k points)
0 votes
As I wrote, I have added a requirement to support mocking statics and Clover.NET.

The code change is needed for all Mocks.
answered by scott (32k points)
0 votes
Hi Scott.
We were wondering when you might expect that this feature will be released.
Thanks.
answered by jnapier (9.6k points)
0 votes
Hi,
This might take some time, I will try to push this high on our list.
answered by scott (32k points)
0 votes
Hi,
This is implemented in version 3.1 (Professional and Enterprise Editions)
answered by scott (32k points)
...