We are trying to put together a script using MSBuild to run our unit tests. This uses NUnit as the unit testing engine and JustMock for the mocking framework. We have the 2012 Q1 full release of JustMock, Nunit 2.5.10 and MSBuild 4.0.
When we run the unit tests in Visual Studio 2010 (using Resharper) all the unit tests run without any problem. When we try to run the unit tests via MSBuild we get:
Test Error : Cecil.SharePoint.Foundation.UnitTests.Model.WorkspaceTests.ModelTestBase`1.SaveExisting
Telerik.JustMock.MockException : There were some problems intercepting the mock call. Optionally, please make sure that you have turned on JustMock's profiler while mocking concrete members.
at Telerik.JustMock.Expectations.Expectation.ThrowForInvalidCall(IInvocation invocation)
at Telerik.JustMock.Mock.<>c__DisplayClass1`1.<Arrange>b__0(MockContext`1 x)
at Telerik.JustMock.MockContext.Setup[TDelgate,TReturn](Instruction instruction, Func`2 function)
We are using the JustMockRunner and the MSBuild targets (JustMockStart & JustMockStop) but the tests are still failing.
What else do we need to do to get the testings running?
Craig
6 Answers, 1 is accepted
Thanks again for contacting us. In configuring your test with JustMockRunner and NUnit I would recommend you to take a look at this following post:
http://www.telerik.com/help/justmock/scenarios-running-jm-profiler-outside-visual-studio.html
In addition, if you are using TFS 2010 for CI then you can also take a look at the following post that shows you configuring JustMock using the new code activity workflow that is shipped from Q1 2012.
http://www.telerik.com/help/justmock/integration-code-activity-workflow.html
Kind Regards
Ricky
the Telerik team
We have already tried using the JustMockRunner tool hence the why I posted. What else can we try?
Craig
I modified the test code so it will lauch the debugger before executing any tests, but the debugger is never launched so it looks like the code is hanging prior to running the tests. However I can see that nUnit has started and both the cor_enable_profiling and cor_profiler environment variables are set.
Craig
Thanks again for reporting the problem. I am attaching the updated JustMockRunner.exe sample project that is working as expected. I am using the latest version of JustMock (Q1) that comes with JustMockRunner.exe in %InstallDir%\Libraries folder.
Let me know if it is working for you. In your project while using JustMockRunner please also verify if the parameters are passed as described in the documentation.
Kind regards,
Mehfuz
the Telerik team
Thanks for replying. We'd just found out what the problems were yesterday and I hadn't updated this post yet.
The first problem is we are unit testing a .NET 3.5 application, so we needed to set an additional environmental variable - COMPLUS_ProfAPI_ProfilerCompatibilitySetting. This needed to be set to EnableV2Profiler. We have written a modified version of the test runner that includes this (plus some other changes we needed.)
The second problem is we needed the Telerik.CodeWeaver.Hook.dll assembly copied to the binaries folder. In our build script we are only copying over the bare minimum of assemblies.
Once we made these two changes the unit tests now run as they should.
Craig
It's great that things are now working for you. I will keep a note to update JustMockRunner.exe with COMPLUS_ProfAPI_ProfilerCompatibilitySetting variable.
Thanks again for pointing it out and I am also adding some telerik points to your account.
Kind Regards,
Ricky
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>