Running NUnit test and mocking statics

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    1 posts
    Member since:
    Feb 2012

    Posted 17 Feb 2012 Link to this post


    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:

    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.

  2. Ricky
    Ricky avatar
    467 posts

    Posted 17 Feb 2012 Link to this post

    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.
    However, you need to install JustMock as it registers the profiler to be used with this tool.
    Hope this answers your question.

    Kind Regards,
    the Telerik team

    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top