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 am brand new to all testing technology under .NET. I am evaluating Isolator with NUnit.

I am very impressed by the capabilities of Isolator. The documentation and sample projects are excellent. I am confident that this technology will make it possible for us to fully test our code base in an automated way, even though the code was written without regard to testability.

Unfortunately, I cannot get Isolator to run without crashing the NUnit test runner. I am able to run other NUnit-based tests that don't use Isolator, such as the test examples from "The Art of Unit Testing".

Here are the details:

My development PC is running Windows 7 Professional 64-bit. I'm using Visual Studio 2008 Professional SP1. My code under test is an X86 application written in C# targeting .NET Framework 3.5 SP1. The code under test ultimately runs on 32-bit Windows 7, but during development it has to run on my 64-bit machine.

My test project is also configured as x86. It references the nunit.framework dll for NUnit 2.5.10, and the TypeMock and TypeMock.ArrangeActAssert dlls for Isolator 6.1.

I have read the Isolator.NET help topic "64 bit machines". I have run corflags.exe to set every executable in the NUnit bin directory to 32-bit. It wasn't clear from the help topic if this step was also required for tmockrunner.exe. I've tried it both ways.

From a DOS command prompt, if I run
nunit-console-x86.exe BPT.Tests.dll

it complains that Typemock isolator is not enabled, as expected.

If I run
tmockrunner nunit-console.exe BPT.Tests.dll

nunit immediately throws a System.BadImageFormatException. I guess that is expected, too.

If I run
tmockrunner nunit-console-x86.exe BPT.Tests.dll

nunit launches and crashes, with the Windows "NUnit-Console has stopped working" system dialog. Here is the console output that came out before the crash:

C:Users	crewsDocumentsBPTCommonSoftware	runkCodeBPTinBryan Debug>tmockrunner nunit-console-x86.exe BPT.Tests
Typemock Isolator Enterprise License - Maintenance will expire in 8 day(s)
NUnit version
Copyright (C) 2002-2009 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
  CLR Version: 2.0.50727.5448 ( Net 2.0 )

ProcessModel: Default    DomainUsage: Single
Execution Runtime: Default

Is there any other way to see more detailed diagnostic information? Have I missed a newbie configuration step?

Thank you for any help you can provide,

Tim Crews
Senior Staff Engineer
GECO, Inc.
asked by timcrews (720 points)

3 Answers

0 votes
I converted the project to use MSTest instead. MSTest crashes as well. Windows displays "VSTestHost.exe has stopped working". I get the following console output:

C:Users	crewsDocumentsBPTCommonSoftware	runkCodeBPTinTacoma Debug>tmockrunner mstest /testcontainer:Bpt.Test
Typemock Isolator Enterprise License - Maintenance will expire in 7 day(s)
Microsoft (R) Test Execution Command Line Tool Version 9.0.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.

Loading Bpt.Tests.dll...
Starting execution...

Final Test Results:
Results               Top Level Tests
-------               ---------------
Aborted               BPT.ReadingCreditCardTests.Enter_Initially_DisplaysPleaseWait
Not Executed          BPT.ReadingCreditCardTests.Enter_Initially_EnablesCardReader
Not Executed          BPT.ReadingCreditCardTests.Enter_Initially_SetsUpTimeout
0/3 test(s) Passed, 1 Aborted, 2 Not Executed

Test Run Error.
  Aborted       1
  Not Executed  2
  Total         3
Results file:      C:Users	crewsDocumentsBPTCommonSoftware	runkCodeBPTinTacoma DebugTestResults	crews_META
 2011-11-01 15_02_35.trx
Run Configuration: Default Run Configuration

Run has the following issue(s):
Test host process exited unexpectedly.

I guess I'm going to uninstall and re-install Typemock Isolator.
answered by timcrews (720 points)
0 votes
The Typemock Isolator example tests all run without crashing.

All of the NUnit examples from "The Art of Unit Testing" run without crashing.

I added one of the Typemock Isolator examples to my own project, and converted it to use NUnit. It runs fine.

So apparently my problem is with my test code.
answered by timcrews (720 points)
0 votes
To future readers of this thread:

The problem was indeed with my test case. I was fumbling around trying to figure out how to mock a delegate. I was doing it wrong. I have now figured a way to do it, although I had to hand-create a mock object instead of using Isolator.

I am a little disappointed that a simple coding error like this would cause a crash of the testing framework, instead of a useful error message and a graceful termination of the test. Nevertheless, I am up and running now and continue developing more tests with what I have learned.


Details of the delegate problem:

I have a delegate type declared like this:

public delegate bool HandlerType(EventBase EventToHandle);

I have a function that takes a single argument of this type:

public void RegisterEvent<ID1> (EventBase.HandlerType TheHandler)
    where ID1 : PrimaryEventIdType

I needed to confirm that this function was called by my code under test. Here's how I did it:

EventBase.HandlerType FakeHandler = delegate(EventBase eb) { return true; };
Isolate.WhenCalled(() => state.RegisterEvent<TimeoutEvent>(FakeHandler)).IgnoreCall();

// Called my code under test here...

Isolate.Verify.WasCalledWithAnyArguments(() => state.RegisterEvent<TimeoutEvent>(FakeHandler));

As you can see, I did not use Isolator to mock the HandlerType delegate, but created my own simple stub object. If there is an automatic way to mock such an object, I would be glad to hear about it.
answered by timcrews (720 points)