chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
I am evaluating TypeMock for possible use in our company. I have tried some examples but when I run the tests via the NUnit GUI, I am told that TypeMock.NET is not enabled and tells how I might enable it. However, TypeMock.NET is enabled in VS 2005 and when I run 'mocking_on.bat' I still get the same message. I also tried using TMockRunner but could not tell what this was doing!

What am I doing wrong?

John Kirby
asked by johnkirby (1.6k points)
Hey,

Can you please open a ticket and send us the logs to Support@typemock.com? Thanks!

11 Answers

0 votes
Hi,
Welcome to TypeMock.
Here is how to run the NUnit-Gui.

:arrow: On the command line:
>mocking_on.bat
>nunit-gui.exe ...

:arrow: If you are creating your own batch file, don't use 'call mocking_on.bat' use the following:
TMockRunner.exe nunit-gui.exe ...

For more information see the running typemock documentation

In any case if this doesn't help. send me the instructions how you run it, so that I can help you.
answered by scott (32k points)
0 votes
Hello. I am having the same problem as John Kirby. I'm using Visual Studio .net 2003. I'm also using the TestDriven plugin. The typemock documentation seems to imply that I should be able to enable and run directly from GUI. Not sure I understand what I am supposed to do.


What is "nunit-gui.exe"? I don't see that anywhere on my computer.


Shawn
answered by shawn1874 (260 points)
0 votes
Hi
To enable TypeMock from gui check the tools menu
You should see 'Disable TypeMock.NET' which means TypeMock is enabled
(This is the default when VS is started)
Or 'Enables TypeMock.NET'' which means TypeMock is disabled.

To run the tests from VS 2003 just run the tests with TestDriven when TypeMock is enabled.

nunit-gui.exe is part of Nunit framework for running unit tests.

Hope it helps. please tell me if you need more info.
answered by ohad (35.4k points)
0 votes
:idea: Since version 4.2 of NUnit the nunit-gui.exe is now called nunit.exe

:arrow: Running the test should be really simple:
Just run your tests using TestDriven.NET (Right Click on test and hit Run Tests).
Try it and if it doesn't work post the error and we can help you out
answered by scott (32k points)
0 votes
First, I do see 'Disable TypeMock.NET' which means TypeMock is enabled.

I'm using typemock.net v2.3.1 and testdriven.net v1.0.

Running the test should be really simple:
Just run your tests using TestDriven.NET (Right Click on test and hit Run Tests).
Try it and if it doesn't work post the error and we can help you out


When I try this, I get the following output:

Info: Test Execution
Info: Exploring Fa22BuilderTests, Version=1.0.2732.17030, Culture=neutral, PublicKeyToken=null
Info: MbUnit 2.22.0.0 Addin
Info: Found 1 tests
Info: [failure] SecurityValidatorTest.setUp.verifyAllowAll_Success.tearDown
TestCase 'SecurityValidatorTest.setUp.verifyAllowAll_Success.tearDown' failed:
*** MockInserter not running, please run 'mocking_on.bat' before running the tests
TypeMock.TypeMockException
Message:
*** MockInserter not running, please run 'mocking_on.bat' before running the tests
Source: TypeMock
StackTrace:
at TypeMock.MockManager.Init(Boolean collectAllCalls)
at TypeMock.MockManager.Init()
X:FA22SDFSLGTSourceFa22DesignXDE_ModelFa22BuilderTestsControllerCommandsBuildCommandsSecurityValidator.cs(74,0): at Slgt.Controller.Commands.BuildCommands.SecurityValidatorTest.setUp()

Info: [reports] generating HTML report
TestResults: file:///x:/fa22/sdf/slgt/source/fa22/design/xde_model/fa22buildertests/bin/debug/Fa22BuilderTests.Tests.html

0 succeeded, 1 failed, 0 skipped, took 0.00 seconds.

Here is the contents of the 'mocking_on.bat' file

set Cor_Enable_Profiling=0x1
set COR_PROFILER={B146457E-9AED-4624-B1E5-968D274416EC}
@REM TMOCK_VERBOSE

running the mocking_on.bat file doesn't seem to change anything. Any ideas?

[/b]
answered by shawn1874 (260 points)
0 votes
John,
Are you running x64 Windows?
If you are you must either install the x64 bit or make sure that you run in x32bit mode.
See Understanding 64 bit

To run in x32 bit: do
:arrow: corflags.exe /32BIT+ "Program FilesTestDriven.NETProcessInvocator.exe"
answered by scott (32k points)
0 votes
Hi
You are using old versions of TypeMock (current version 4.0.1) and TestDriven.NET (current version 2.7.2111)
The integration between the tools is much better now.
Can you please upgrade and tell me what the results?

:arrow: The mocking_on.bat will work if you run the tests
from the command line or bat file
call <TypeMock Path>mocking_on.bat
call <MBunit Path>MbUnit.Cons.exe YourTest.dll
call <TypeMock Path>mocking_off.bat


another way to run from command line is use TMockRunner.exe
like this:
<TypeMock Path>TMockRunner.exe <MBunit Path>MbUnit.Cons.exe YourTest.dll


In any case I would strongly recommend you to upgrade both tools.
answered by ohad (35.4k points)
0 votes
First; can't really upgrade on spur of moment. For whatever reason, the company hasn't done that and I do not have authorization to do that myself.

I'm sure I am not running 64 bit windows. I'm running in windows xp environment with sp2.
answered by shawn1874 (260 points)
0 votes
Hi
Can please try one of the command line options
(TmockRunner.exe or calling mocking_on.bat) and tell me what are the results?
answered by ohad (35.4k points)
0 votes
I ran mocking_on.bat from a visual studio command prompt, as opposed to a regular command prompt and this is the output of that:

Setting environment for using Microsoft Visual Studio .NET 2003 tools.
(If you have another version of Visual Studio or Visual C++ installed and wish
to use its tools from the command line, run vcvars32.bat for that version.)

C:Documents and Settingss381205>cd C:Program FilesTypeMock.NETTypeMock.NET

C:Program FilesTypeMock.NETTypeMock.NET>mocking_on.bat

C:Program FilesTypeMock.NETTypeMock.NET>set Cor_Enable_Profiling=0x1

C:Program FilesTypeMock.NETTypeMock.NET>set COR_PROFILER={B146457E-9AED-4624-
B1E5-968D274416EC}
C:Program FilesTypeMock.NETTypeMock.NET>devenv

C:Program FilesTypeMock.NETTypeMock.NET>


Now when i ran the tests, some of the tests are working now and some don't. I seem to be past the "not running" error. Now I am getting some kind of problem with the framework. Functions that are setup to be mocked are not running and the framework seems to be throwing some exceptions. Here is some example output from a test. In this case, it is complaining that methods aren't being called. They are being called when i step into with debugger; but the methods in question are suppossed to be mocked. The actual methods are getting called as opposed to the framework mocking them.

Info: Test Execution
Info: Exploring Fa22BuilderTests, Version=1.0.2733.16977, Culture=neutral, PublicKeyToken=null
Info: MbUnit 2.22.0.0 Addin
Info: Found 1 tests
Info: [failure] SecurityValidatorTest.setUp.verify_Success.tearDown
TestCase 'SecurityValidatorTest.setUp.verify_Success.tearDown' failed:
TypeMock Verification: Method Slgt.Controller.Commands.BuildCommands.SecurityValidator.verifyF22Messages() has 2 more expected calls
Method Slgt.Controller.Commands.BuildCommands.SecurityValidator.verifyWritedownLabel() has 2 more expected calls
Method Slgt.Controller.Commands.BuildCommands.SecurityValidator.verifyWritedownAgent() has 2 more expected calls
Method Slgt.Controller.Commands.BuildCommands.SecurityValidator.verifyF22Writedowns() has 2 more expected calls
Method Slgt.Controller.Commands.BuildCommands.SecurityValidator.verifyCorba() has 2 more expected calls

Info: [reports] generating HTML report
TestResults: file:///x:/fa22/sdf/slgt/source/fa22/design/xde_model/fa22buildertests/bin/debug/Fa22BuilderTests.Tests.html

0 succeeded, 1 failed, 0 skipped, took 0.00 seconds.


Here is an example of some of the mock setups:
// Set up mocks
Mock mockSecurityValidator =
MockManager.Mock(typeof(SecurityValidator), Constructor.NotMocked);
mockSecurityValidator.ExpectAndReturn("verifyWritedownAgent", new ArrayList(),2);
mockSecurityValidator.ExpectAndReturn("verifyWritedownLabel", new ArrayList(),2);

The tests seem to run fine on other people's machines and they don't remember doing anything special; other than installing the applications. They are also running with same version as I. I've seen all the tests run perfectly on someone else's machine. So there has to be some kind of setup problem remaining on my computer. Any test that does NOT mock any method in a class runs fine. So there is still some kind of setup problem preventing functions from being mocked properly.
answered by shawn1874 (260 points)
...