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

Use JustMock in MSBuild

10 Answers 330 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Roland Vonk
Top achievements
Rank 1
Roland Vonk asked on 18 Sep 2012, 11:14 AM
I'm trying to get JustMock working in an MSBuild unit test task. I keep getting the dreaded 'Profiler must be enabled' error.

It works in Visual Studio 2012 using the ReSharper test runner. xUnit.net is used as unit testing framework. I'm calling a .msbuild file, which looks like this:

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="C:\Program Files (x86)\Telerik\JustMock\Libraries\JustMock.targets" />
 
    <UsingTask AssemblyFile="$(MSBuildProjectDirectory)\..\packages\xunit.runners.1.9.1\tools\xunit.runner.msbuild.dll" TaskName="Xunit.Runner.MSBuild.xunit" />
 
    <Target Name="Build">
        <JustMockStart />
        <xunit Assembly="bin\Release\WebshopNG.Tests.dll" />
        <JustMockStop />
    </Target>
</Project>

Superfluously, before calling msbuild.exe I set the following environment variables:

COR_ENABLE_PROFILING=0x1
COR_PROFILER={b7abe522-a68f-44f2-925b-81e7488e9ec0}

I keep getting the following error in the event log:

.NET Runtime version 4.0.30319.17929 - Loading profiler failed.  COR_PROFILER is set to an invalid CLSID: '{b7abe522-a68f-44f2-925b-81e7488e9ec0}'.  HRESULT: 0x800401f3.  Process ID (decimal): 5576.  Message ID: [0x2502].

I've tried re-registering the Telerik.CodeWeaver.Profiler.dlls, but that did nothing. Googling the error yields nothing concrete, so I'm at a loss where to start.

10 Answers, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 20 Sep 2012, 09:59 PM
Hi Roland,
Thanks again for contacting us. Here are few things that you can do:

1. You can try running it using JustMockRunner console app and see if that works. More information on this can be found at this post:
http://www.telerik.com/help/justmock/scenarios-running-jm-profiler-outside-visual-studio.html

2. Make sure that you have copied the Telerik.CodeWeaver.Api.DLL to the folder where Telerik.JustMock.DLL is located.

3. Please also try configuring the tests in build server using code activity workflow that ships with Justmock. Details on this can be found here:

http://www.telerik.com/help/justmock/integration-code-activity-workflow.html

4. Finally, I will investigate more on this in coming days to see if doing the same in VS 2012 also fails my tests.


Kind Regards
Mehfuz
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Roland Vonk
Top achievements
Rank 1
answered on 24 Sep 2012, 12:49 PM
1. I tried running the tests with JustMockRunner. The tests still failed, and I got the following event in my event log:
.NET Runtime version 4.0.30319.17929 - Loading profiler failed during CoCreateInstance.  Profiler CLSID: '{D1087F67-BEE8-4f53-B27A-4E01F64F3DA8}'.  HRESULT: 0x80040154.  Process ID (decimal): 11912.  Message ID: [0x2504].

2. I did and now I got a different message in the event log when running it from MSBuild:
.NET Runtime version 4.0.30319.17929 - The profiler has requested that the CLR instance not load the profiler into this process.  Profiler CLSID: '{b7abe522-a68f-44f2-925b-81e7488e9ec0}'.  Process ID (decimal): 4016.  Message ID: [0x2516].

3. We're not using TFS, we're using Mercurial and TeamCity for our SCC/CI needs.

4. The tests do succeed in VS2012. It's just that they don't succeed outside of Visual Studio.
0
Accepted
Ricky
Telerik team
answered on 27 Sep 2012, 04:06 PM
Hi Roland,

Thanks again for contact us. 

Are you using a local system account in your build machine? In that regard, I would ask you to go to your environment variable settings and set JustMock instance variable in the following way:





Next, restart the machine and see if that solves your issue. Here is the link the from Microsoft that has more information on it:


http://support.microsoft.com/kb/821761#appliesto


Kind Regards
Mehfuz
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Ilya
Top achievements
Rank 1
answered on 28 Sep 2012, 06:13 AM
Hi,
could you please explain how JUSTMOCK_INSTANCE variable works ? 
Because I struggled one day with investigation how I can use justmock tests with profiler requests in my build process  without changing build processing such as adding JustMockRunner activity and after that I found that setting up JUSTMOCK_INSTANCE to "0" works when I set it for process who would start MsTest.exe 
0
Roland Vonk
Top achievements
Rank 1
answered on 28 Sep 2012, 10:34 AM
Setting JUSTMOCK_INSTANCE to 0 proved to be the solution. I was able to run the tests in the stand-alone test runner and in MSBuild on my machine. I set those variables in the TeamCity configuration, and JustMock now runs perfectly on our build server. Thanks!
0
Ricky
Telerik team
answered on 02 Oct 2012, 07:47 PM
Hi Ronald,

It's great to hear that JustMock is now running perfectly in your build machine. Should you find any other issues please don't hesitate to contact us. 


Kind Regards
Mehfuz
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mohd
Top achievements
Rank 1
answered on 05 Jun 2013, 06:33 AM
HI,
I too need have the need of running the unit test case from msbuild using mstest in TFS. We want to use mstest specifically in the TFS 2010. So . My test case running perfectly fine from Visual 2010 by enabling profiler on from the Telerik menu in visual studion 2010.


Can you help me to get the step of configuring the  existing TFS build definition so that profiler is enabled. As of now the error is profiler need to enabled.

Thanks
Mohd Moyeen
mohd.moyeen@allscripts.com
0
Kaloyan
Telerik team
answered on 05 Jun 2013, 11:51 AM
Hi Moyeen,

I have replied to you in forum thread with ID 701028.

Regards,
Kaloyan
Telerik
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
0
Brian Fu
Top achievements
Rank 1
answered on 28 Jan 2014, 10:14 PM
Hi Kaloyan,
    How do I find the solution in forum thread ID - 701028?

Thanks.
0
Kaloyan
Telerik team
answered on 30 Jan 2014, 11:07 AM
Hi Brian,

In order to integrate JustMock inside your build process, please check our integration articles. There are workflows about configuring JustMock for different TFS version, using code activities or just MSBuild Tasks.

However, if the above mentioned guides do not help you out, please share what the exact issue is and we will be happy to assist you further.

As an addition, you could check this article for known issues that may cause you troubles.

I hope this helps.

Regards,
Kaloyan
Telerik
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
Tags
General Discussions
Asked by
Roland Vonk
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Roland Vonk
Top achievements
Rank 1
Ilya
Top achievements
Rank 1
Mohd
Top achievements
Rank 1
Kaloyan
Telerik team
Brian Fu
Top achievements
Rank 1
Share this question
or