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

Running NUnit test and mocking statics

1 Answer 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 17 Feb 2012, 07:08 AM
Hi,

I have just started using the evaluation version of JustMock. I am trying to run my tests through NUnit in an environment that does not have Visual Studio installed (a build server with .NET 4.0 redist installed). It appears to work for all tests that do not require mocking static methods, however when I attempt to run a test with a mocked static method I get the following error:

MyTest.TestConnect:
Telerik.JustMock.MockException : Profiler must be enabled to mock/assert target MyClass.AStaticMethod(Boolean) method.

When I look up your documentation at this link it only gives information on how to configure the advanced features when using Visual Studio.

Do you guys support using NUnit GUI as the test runner?
Is it possible that there is an issue with the fact that I have not installed JustMock on my build server (I'm just copying the Telerik.JustMock.dll at the moment)?
I am currently building in Release mode as the .NET 4.0 debug dlls are not present on my build server - could this be an issue?

If there is no way to get this working I can just wrap the static methods with a dependency injected adaptor interface, but it would be useful for me to be able to avoid introducing the extra class.

Thanks.

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 17 Feb 2012, 09:16 AM
Hi Ryan,

Thanks again for contacting us.

NUnit GUI is a standalone tool, therefore profiler variables must be set first before running it. We have a tool called JustMock Runner which we are shipping from Q1 2012 in the %Program_Files%\Telerik\JustMock\Libraries folder. Please check out the following blog post where it shows how you can combine JustMockRunner.exe with nunit-console.exe which applies to the GUI tool as well.

http://weblogs.asp.net/mehfuzh/archive/2011/05/24/running-justmock-profiler-outside-of-visual-studio.aspx
 
However, you need to install JustMock as it registers the profiler to be used with this tool.
 
Hope this answers your question.

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 >>
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or