This is a migrated thread and some comments may be shown as answers.

Unable to intercept when running NUnit in MSBuild

6 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 27 Mar 2012, 01:14 AM
Hi,

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

Sort by
0
Ricky
Telerik team
answered on 29 Mar 2012, 11:42 PM
Hi Craig,

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

Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Craig
Top achievements
Rank 1
answered on 01 Apr 2012, 09:38 PM
Hi Ricky,

We have already tried using the JustMockRunner tool hence the why I posted. What else can we try?


Craig
0
Craig
Top achievements
Rank 1
answered on 01 Apr 2012, 10:32 PM
Just to make sure this isn't something from our code, I downloaded the code sample from http://www.telerik.com/help/justmock/scenarios-running-jm-profiler-outside-visual-studio.html and tried running it. We get the same result with the sample - the batch file starts and then just hangs.

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
0
Ricky
Telerik team
answered on 04 Apr 2012, 08:09 PM
Hi 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

Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Craig
Top achievements
Rank 1
answered on 04 Apr 2012, 10:18 PM
Hi Mehfuz,

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

0
Ricky
Telerik team
answered on 05 Apr 2012, 03:51 PM
Hi 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 >>

Tags
General Discussions
Asked by
Craig
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Craig
Top achievements
Rank 1
Share this question
or