Profiler must be enabled to mock error

3 posts, 0 answers
  1. Yi
    Yi avatar
    6 posts
    Member since:
    Jul 2012

    Posted 27 Jan 2013 Link to this post

    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. Yi
    Yi avatar
    6 posts
    Member since:
    Jul 2012

    Posted 28 Jan 2013 Link to this post

    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");

  3. DevCraft R3 2016 release webinar banner
  4. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 28 Jan 2013 Link to this post

    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.
Back to Top