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
0 votes
I have just purchased an enterprise license because I decided I needed to be able to use NCover for the project I am working on.

The problem I am running into is the tests fail when run under NCover but not when I run them without NCover.

I am using NUnit as my testing framework, and have entered my license code in the configuration utility, selected NCover 1.3 and linked it. I have tried to use NCover version 1.3.3 and 1.5 beta (both 1 and 2) with no luck.

An example of the errors I get under NCover is
1) Ulta.Server.MasData.DataQueueTests.LoadQueue : Ulta.Lib.AppException.UltaException : Object reference not set to an instance of an object.
TearDown : TypeMock.VerifyException :
TypeMock Verification: Expected a new instance of Ulta.Lib.Data.DBManager (try using MockAll)
Method Ulta.Lib.Data.DBManager.AddProc() has 2 more expected calls
Method Ulta.Lib.Data.DBManager.ExecuteCommand() has 2 more expected calls
Method Ulta.Lib.Data.DBManager.CreateConnection() has 1 more expected calls
Method Ulta.Lib.Data.DBManager.AddNumberParam() has 2 more expected calls

   at Ulta.Lib.Configuration.ConfigurationManager.GetValue(String sName, String& sValue) in F:System.netKernelLibConfigurationManagerConfigurationManager.cs:line 90
   at Ulta.Lib.ResourceInfo.ResourceManager.Initialize() in F:System.netKernelLibResourceManagerResourceManager.cs:line 130
   at Ulta.Lib.ResourceInfo.ResourceManager.FindResource(String sResourceID, DataRow& drResourceRow) in F:System.netKernelLibResourceManagerResourceManager.cs:line 351
   at Ulta.Lib.ResourceInfo.ResourceManager.GetResource(String sResourceID, DatabaseResource& databaseResource) in F:System.netKernelLibResourceManagerResourceManager.cs:line 160
   at Ulta.Lib.Data.DBManager.CreateConnection(ResourceManager ResMgr, String LogicalName)
   at Ulta.Server.MasData.DataQueue..ctor(Parameters Parameters) in W:WorkMasData.NetMasDataDllDataQueue.cs:line 49
   at Ulta.Server.MasData.DataQueueTests.LoadQueue() in W:WorkMasData.NetMasDataTestsDataQueueTests.cs:line 138
--TearDown
   at TypeMock.MockManager.Verify()
   at Ulta.Server.MasData.DataQueueTests.TestTearDown() in W:WorkMasData.NetMasDataTestsDataQueueTests.cs:line 104


I have tried changing the call to MockAll with the same results. This only occur when run with the command line:
"c:program files
cover
cover.console" /c "C:Program FilesNUnitin
unit-console.exe" MasDataTests.dll


If I run
"C:Program FilesNUnitin
unit-console.exe" MasDataTests.dll

it all works fine, all tests succeed.

I tried turning verbose on (set TMOCK_VERBOSE=1) and looking at the TypeMock.out that is the NCover directory but there is no IL code in that file to send along.

I am sure I am missing something, but can't figure out what it is. I have use NCover before without TypeMock successfully, so I am at a loss here.


Darryn Glass
asked by echmyr (2.2k points)

18 Answers

0 votes
Hi,
This might be a bug.
Please set tracing on (set TMOCK_VERBOSE=1) and look for a file called LinkedProfilers.out in the Ncover directory, and send the results.

Please see if the same happen when you run only ONE test
answered by scott (32k points)
0 votes
LinkedProfiles.out as requested.

Cannot read EnvName0  => The system cannot find the file specified.

Adding profiler: {4BD66EB5-1F60-4bbd-8820-5E13080D49BE}
Loaded C:Program FilesNCoverCoverLib.dll 
Adding typemock profiler
Loaded C:Program FilesTypeMock.NETMockWeaver.dll 


This is being run with the 1.3.3 version of NCover (if that makes a difference) and TypeMock 3.0.1.1.
answered by echmyr (2.2k points)
0 votes
Hi,
There could be a few reasons for this.

1. It seems that you are running the coverage under .NET 2.0. If you are NCover 1.3.3. doesn't support this.
2. To succesfully run NCover and TypeMock you don't have to run 'mocking_on' or 'tmockrunner' - actually you shouldn't, instead just 'link' TypeMock and run NCover.
3. The TypeMock log files are in the NUnit directory (the log files in the Ncover directory will appear if you run 'mocking_on' and are the log for the ncover.console that is not mocked so that is why the file has no IL code)
4. Please run NCover with "/a assembly" or else it doesn't work.

I will install 1.5 Beta and check it too.
answered by scott (32k points)
0 votes
Ok, I am a bit confussed and not at work anymore, so I can't try this there, so I put in on my home computer (where I also work) and tried it.

First I figured I would check to see if I had the latest version, and found I didn't. I installed version 3.0.2.

Then I took to call to mocking_on out of my batch file I use to run the coverage tests. It game me the error about mocking being off. So I ran the cofiguration tool, re-registers and set the mocking choice to NCover 1.3, clicked Link with TypeMock and then clicked the close button.

**!!!!!CRASH
See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at l.a(Object A_0, CancelEventArgs A_1)
   at System.Windows.Forms.Form.OnClosing(CancelEventArgs e)
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
TypeMock
    Assembly Version: 3.0.2.0
    Win32 Version: 3.0.2.0
    CodeBase: file:///C:/Program%20Files/TypeMock.NET/TypeMock.NET/TypeMock.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
Configuration
    Assembly Version: 3.0.2.0
    Win32 Version: 3.0.2.0
    CodeBase: file:///C:/Program%20Files/TypeMock.NET/TypeMock.NET/Configuration.DLL
----------------------------------------
System.Xml
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
8srpps6j
    Assembly Version: 0.0.0.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
k3_s9xnf
    Assembly Version: 0.0.0.0
    Win32 Version: 1.1.4322.2032
    CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.


This happened at work also, but I could never get it to do it again, but at work when I would try to re-link NCover, it would not show up in the list, even with the check box unchecked. I am going to start tomorrow off by uninstalling TypeMock and NCover and reinstalling them to see what happens...

As a side note, at home I do have version 1.5 of NCover installed (at work we are not doing any 2.0 stuff yet, but at home I am).
answered by echmyr (2.2k points)
0 votes
Hi,
There is no need to reinstall the works.
It is very simple.
:twisted: The TypeMock configurator has a bug, when you try to close it while you have a coverage linked then it causes the crash, we will try to post a fix for this soon.

:arrow: About NCover 1.3: Link and then run ncover should work. remember you must cover at least one assembly
:arrow: NCover 1.5.1:
Open typemockconfig.xml in the TypeMock.NET installation directory, find the line begining with <Profiler Name="NCover" and change to Clsid="{6287B5F9-08A1-45E7-9498-B5B2E7B02995}"
Link and then run ncover should work.
answered by scott (32k points)
0 votes
I seem to just be getting more confused. Here is this mornings update.

I added the lines
    <Profiler Name="NCover1.5" Clsid="{6287B5F9-08A1-45E7-9498-B5B2E7B02995}" DirectLaunch="false">
      <EnvironmentList />
    </Profiler>

to the typemockconfig.xml file, linked that profile and tried to run my tests (just the nunit-gui version not even using NCover yet). Nothing happened. The GUI did not come up or anything. I looked in task manager and found the NUnit GUI running about 99% of CPU usage. Just to test, I ran the cofiguration again. Strangly it did not show that I had any profiler linked (this is on 3.0.1). I Cliked Link and the Unlink and re-ran NUnit GUI. This time it came up without a problem.

If I get time I will try to write a simple test that I can post the code for and the steps I have gone through to try to create this problem.
answered by echmyr (2.2k points)
0 votes
Testing Steps:

Testing Under NUnit 2.2.6 for .NET 1.1
NCover 1.3.3
TypeMock 3.0.1

Entered my Registration for TypeMock

Created a new VS 2003 project for testing.

Ran my test suite (in NUnit Gui). Ran Successfully.

Linked TypeMock to NCover 1.3
Closed TypeMock Configuration Tool.

Ran my test suite (in NUnit Gui). Ran Successfully.
Ran my test suite (in NUnit Console). Ran Successfully.
Ran the command
"c:program files
cover
cover.console" /c "C:Program FilesNUnitin
unit-console.exe" MockedTests.dll /a ToBeMockedDLL

Ran Successfully but with no output in the coverage.xml file
<?xml version="1.0" ?>
<?xml-stylesheet href="coverage.xsl" type="text/xsl" ?>
<coverage>
</coverage>


Upgraded NCover to 1.5.1 beta 2
Added this line to typemockcondfig.xml
    <Profiler Name="NCover1.5" Clsid="{6287B5F9-08A1-45E7-9498-B5B2E7B02995}" DirectLaunch="false">
      <EnvironmentList />
    </Profiler>


Relinked TypeMock to NCover 1.5
Closed TypeMock Configuration

Ran my test suite (in NUnit Gui). Tests Ran Successfully but NUnit GUI Crashed on exit.
Ran my test suite (in NUnit Console). Nunit Console Crashed on first Run.

Unlinked NCover 1.5.

Ran my test suite (in NUnit Gui). Ran Successfully.
Ran my test suite (in NUnit Console). Ran Successfully.

Relinked TypeMock to NCover 1.5
Closed TypeMock Configuration

Ran the Command (since the GUI will at least run)
"c:program files
cover
cover.console" "C:Program FilesNUnitin
unit-gui.exe" MockedTests.dll //a ToBeMockedDLL

Received the error
NCover.Console.exe - Fatal Error
CLR error: 80004005
The Program will now terminate


Here is the code I am "testing"
using System;

namespace ToBeMockedDLL
{
   /// <summary>
   /// Summary description for IMockedClass.
   /// </summary>
   public class MockedClass
   {
      public MockedClass()
      {
      }
      
      public int RandomNumber()
      {
         Random rand = new Random();
         int result = Convert.ToInt32(rand.Next());
         return result;
      }

      public int RandomNumber(int Max)
      {
         Random rand = new Random();
         int result = Convert.ToInt32(rand.Next(Max));
         return result;
      }

      public int RandomNumber(int Min, int Max)
      {
         Random rand = new Random();
         int result = Convert.ToInt32(rand.Next(Min, Max));
         return result;
      }
   }

   /// <summary>
   /// Summary description for Dice.
   /// </summary>
   public class Dice
   {
      MockedClass mocked;
      
      public Dice()
      {
         mocked = new MockedClass();
      }
      
      public int Rolld6(int count)
      {
         int result = 0;      // Can't get 0 from dice
         
         if (count < 1)
            throw new ArgumentNullException("You must have at least 1 die to roll");
            
         for (int number = 0; number < count; ++number)
         {
            result += mocked.RandomNumber(1,6);
         }
         
         return result;
      }

      public int Rolld10(int count)
      {
         int result = 0;      // Can't get 0 from dice
         
         if (count < 1)
            throw new ArgumentNullException("You must have at least 1 die to roll");
            
         for (int number = 0; number < count; ++number)
         {
            result += mocked.RandomNumber(1,10);
         }
         
         return result;
      }

      public int Rolld100(int count)
      {
         int result = 0;      // Can't get 0 from dice
         
         if (count < 1)
            throw new ArgumentNullException("You must have at least 1 die to roll");
            
         for (int number = 0; number < count; ++number)
         {
            result += mocked.RandomNumber(1,100);
         }
         
         return result;
      }
   }
}



Here is my test code
using System;
using ToBeMockedDLL;
using NUnit.Framework;
using TypeMock;

namespace MockedTests
{
   /// <summary>
   /// Summary description for Class1.
   /// </summary>
   [TestFixture]
   public class Tests
   {
   
      [SetUp]
      public void TestSetup()
      {
         MockManager.Init();
      }
      [TearDown]
      public void TestTearDown()
      {
         MockManager.Verify();
      }

      [Test]
      public void Roll1d6()
      {
         Mo
answered by echmyr (2.2k points)
0 votes
Hi,
You have actually found a few bugs :twisted:
Thanks for reporting them.

I sent the fixes offline.
It should fix:
:arrow: Support For NCover 1.5.1 Beta 2
:arrow: Error while exiting TypeMock Configuration
:arrow: Error of recursive linking (100% CPU)
:arrow: Error running NCover
:arrow: CLR error 80004005


Please tell me if it helped
answered by scott (32k points)
0 votes
Thanks, I got the files, but had to work on another project today that is rolling out this week. I will try to give them a run tomorrow and let you know the results...
answered by echmyr (2.2k points)
0 votes
Ok, the first problem I ran into was the replaced TypeMock.exe will not run. I get an error
Windows cannot access the specified device, path, or file.  You may not have the appropriate permissions to access the item.


The old one still runs fine. Does this one require .NET 2.0 release? I am pretty sure (since we do not do do 2.0 stuff yet) that it is not on my machine. I will d/l it and install it if needed.
answered by echmyr (2.2k points)
...