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

Cannot mock … The profiler must be enabled to mock, arrange or execute the specified target

9 Answers 2925 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 06 May 2015, 06:29 AM
I have the following in a test (my first ever JustMock test, I might add)...

var template = Mock.Create<MessageType>
Mock.Arrange(() => template.Subject).Returns("This template has Zero tokens.");
Mock.Arrange(() => template.Body).Returns("This template has {{number}} of {{tokens}}.");


The class being Mocked looks like this ...

public class MessageType : BaseBusinessEntity
{
    public string Body { get; set;}
    public int DigestsToBeIncludedOn { get; set; }
    public Guid MessageReference { get; set; }
    public int MessageTypeId { get; set; }
    public string Name { get; set; }
    public int PredefinedRecipients { get; set; }
    public string Subject { get; set; }
}

When I attempt to run the test I get ...

> Error Message: Test method
> Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens
> threw exception:  Telerik.JustMock.Core.ElevatedMockingException:
> Cannot mock 'System.String get_Subject()'. The profiler must be
> enabled to mock, arrange or execute the specified target. Stacktrace: 
> at
> Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo
> member)  at
> Telerik.JustMock.Core.MocksRepository.CheckMethodInterceptorAvailable(IMatcher
> instanceMatcher, MethodBase method)  at
> Telerik.JustMock.Core.MocksRepository.AddArrange(IMethodMock
> methodMock)  at
> Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](Expression
> expr, Func`1 methodMockFactory)  at
> Telerik.JustMock.Mock.<>c__DisplayClass8`1.<Arrange>b__6()  at
> Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1
> guardedAction)  at Telerik.JustMock.Mock.Arrange[TResult](Expression`1
> expression)  at
> Genesis.Service.Implementation.Tests.DigestFixture.ShouldCorrectlyExtractTemplateTokens()
> in
> c:\Genesis\Development\Genesis.Service.Implementation.Tests\DigestFixture.cs:line
> 46

Can anyone point out what I've done wrong?

9 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 07 May 2015, 11:35 AM
Hi Stuart,

It appears that the profiler is not enabled. You should enable the JustMock Profiler from the JustMock menu in Visual Studio.

Please refer to our knowledge base article explaining how to tackle "profiler not enabled" issues.

Regards,
Stefan
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Mohammad
Top achievements
Rank 1
answered on 24 Aug 2018, 10:15 PM
What If I am using the nugget package and didn't actually install the whole package?
0
Ivo
Telerik team
answered on 29 Aug 2018, 09:58 AM
Hello Mohammad,

I am afraid that you will not be able to run elevated tests using JustMock nuget package since it deploys the free version. Here is an article which clearly states the differences.

Regards,
Ivo
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Franco
Top achievements
Rank 1
answered on 17 Sep 2018, 01:37 PM
Hello, is it possible to enable the profiler for Rider IDE ? also I read here that installs the free version but if we decide to buy the license, we won't be able to use to install the
0
Ivo
Telerik team
answered on 19 Sep 2018, 11:46 AM
Hello Franco,

I suppose that you are interested in advanced features that JustMock delivers with commercial version. All these features could be enabled via environment using dedicated variables, please refer to this article to see how exactly. More information about 'registry free profiler' could be also found on MSDN. Since there is no officially existing integration with Rider IDE the only possible way to enable JustMock elevated mode is to use the similar approach like command prompt, i.e. to prepare a small bootstrap batch script which setups the required environment and than launches the IDE. JustMock configuration tool would be available too, for more details please refer to this topic in documentation.

Regards,
Ivo
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Rafael
Top achievements
Rank 2
answered on 18 May 2020, 03:24 PM

On the latest Justmock version I cannot find the Telerik.JustMock.Tests.dll that I need to run the commands from the article 

https://docs.telerik.com/devtools/justmock/integration/windows-batch-command#how-to-run-profiler-enabled-justmock-tests-in-command-prompt

Also the VS 2017 MsTest.exe file I need is located elsewhere: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe"  

--->

SET JUSTMOCK_INSTANCE=1
SET COR_ENABLE_PROFILING=1
SET COR_PROFILER={B7ABE522-A68F-44F2-925B-81E7488E9EC0}

"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:"C:\Program Files (x86)\Telerik\JustMock\Examples\Telerik.JustMock.Tests\bin\Debug\Telerik.JustMock.Tests.dll"

0
Mihail
Telerik team
answered on 18 May 2020, 03:53 PM

Hello Rafael,

The examples have evolved to include even more test scenarios and with that, the path was changed. You can open the following folder "C:\Program Files (x86)\Progress\Telerik JustMock\Examples\CSExamples", build the "Telerik.JustMock.CSExamples.VS2019.sln" solution and use the output dll instead.

I will also encourage you to check the JustMock Console article as JustMock Console is a newer and more powerful tool compared to JustMockRunner.

I hope this information answers your questions

Regards,
Mihail
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Rafael
Top achievements
Rank 2
answered on 18 May 2020, 04:18 PM
Thank you very much for the prompt reply I will review
0
Rafael
Top achievements
Rank 2
answered on 18 May 2020, 09:28 PM
Reviewed further and something that might have success is setting the environment variables in the Build > Unit Testing > Test Runner option area. But Need to test this more but optimistic this might work for me. Now just need to get Selenium and Jasmine testing working.
Tags
General Discussions
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Mohammad
Top achievements
Rank 1
Ivo
Telerik team
Franco
Top achievements
Rank 1
Rafael
Top achievements
Rank 2
Mihail
Telerik team
Share this question
or