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

Profiler must be enabled to mock error

2 Answers 190 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yi
Top achievements
Rank 1
Yi asked on 28 Jan 2013, 04:35 AM
Hi,

I am trying to run my test case using MSTest, but i get below error, it seems profiler is not enabled, how to enable it thru command line?

MESSAGE:
Test method STB.EP.RBS.Test.TransportBooking.DriverComponentTest.testCheckExistDriver threw exception: 
Telerik.JustMock.MockException: Profiler must be enabled to mock/assert target SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated) method.
+++++++++++++++++++
STACK TRACE:
   at Telerik.JustMock.Handlers.InterceptorHandler.Create(Object target, MethodInfo methodInfo, Boolean privateMethod)
   at Telerik.JustMock.MockContext`1.SetupMock(MockExpression`1 expression)
   at Telerik.JustMock.Mock.<>c__DisplayClassd.<Arrange>b__c(MockContext`1 x)
   at Telerik.JustMock.MockContext.Setup[TDelgate,TReturn](Instruction instruction, Func`2 function)
   at Telerik.JustMock.Mock.Arrange(Expression`1 expression)
   at STB.EP.RBS.Test.TransportBooking.DriverComponentTest.testCheckExistDriver() in C:\Project\STB\RBS\Tests\STB.EP.RBS.Test\TransportBooking\DriverComponentTest.cs:line 58

Thanks!

Regards
Suyi

2 Answers, 1 is accepted

Sort by
0
Yi
Top achievements
Rank 1
answered on 28 Jan 2013, 08:34 AM
As suggested by http://www.telerik.com/community/forums/justmock/general-discussions/why-is-the-enable-disable-the-profiler-an-ide-setting.aspx, i add below code in my test case, but it does not work. The test case run in the visual studio working fine, 
but when i try to use MsTest(integrate with CI Jenkins) to run the test case, it always report "Telerik.JustMock.MockException: Profiler must be enabled to mock/assert target SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated) method."

System.Environment.SetEnvironmentVariable("COR_ENABLE_PROFILING", "0x1");
System.Environment.SetEnvironmentVariable("COR_PROFILER", "{b7abe522-a68f-44f2-925b-81e7488e9ec0}");
System.Environment.SetEnvironmentVariable("COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler");

0
Kaloyan
Telerik team
answered on 28 Jan 2013, 09:20 AM
Hi Yi Su,

To enable the JustMock profiler through command line you will need to have the proper environment variables set as follows:
  • JUSTMOCK_INSTANCE = 1
  • COR_ENABLE_PROFILING = 1
  • COR_PROFILER = {B7ABE522-A68F-44F2-925B-81E7488E9EC0}
In order to achieve this, I would recommend you using the JustMockRunner, as it automatically takes care for this. You could try the following approach:
JustMockRunner.exe mstest /testcontainer:YourTestProject.DLL
This will set the profiler variables and will call mstest runner to execute the tests in the certain assembly.

Also, you could further check this link for more information about the "Profiler not enabled" exception, and this about integrating JustMock on build machines.

I hope this helps. Please, contact us again if you have more questions.

All the best,
Kaloyan
the Telerik team
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
Yi
Top achievements
Rank 1
Answers by
Yi
Top achievements
Rank 1
Kaloyan
Telerik team
Share this question
or