Easier legacy unit testing with TypeMock.NET

My blog has moved. You can view this post at the following address: http://www.osherove.com/blog/2005/3/20/easier-legacy-unit-testing-with-typemocknet.html
Published Sunday, March 20, 2005 10:30 PM by RoyOsherove
Filed under:

Comments

Sunday, March 20, 2005 7:45 PM by Jim Arnold

# re: Easier legacy unit testing with TypeMock.NET

(Just for the record - NMock does support mocking classes)

Jim
Monday, March 21, 2005 1:00 AM by Roy Osherove

# re: Easier legacy unit testing with TypeMock.NET

Jim: Oops! My bad, you're right.
Monday, March 21, 2005 1:33 AM by Simon

# re: Easier legacy unit testing with TypeMock.NET

Jim: There is a big difference between the classes that nMock can mock and TypeMock can mock.
First nMock can mock only virtual methods, TypeMock can mock all methods.
Second is the nMock will return a mock object that has to be passed to the tested method. TypeMock will mock a future class that is instantiated somewhere in the call hierarchy of your tested method.
Monday, March 21, 2005 3:41 AM by Piotr Czarnas

# re: Easier legacy unit testing with TypeMock.NET

Don't get too enthusiastic about mocking libraries that use the profiler API. The profiler API works when you have a profiler .dll (provided with TypeMock) loaded into the process. If a profiler is loaded into CLR then only a very limited subset of the debugging API is active. The documentation says that the profiler and debug APIs cannot be used at the same time because of very serious deadlocks in the execution engine.
If you use for example TestDriven.NET and run your unit tests under a debugger (to find a bug) then you must choose: using TypeMock or using NMock + debugger. You cannot debug unit tests that loaded TypeMock.

Probably the only solution would be to create a separate assembly with unit tests that all require TypeMock and write the remaining (majority) of unit tests using NMock.
Monday, March 21, 2005 4:14 PM by Eli

# re: Easier legacy unit testing with TypeMock.NET

Hi Piotr,
We are using TypeMock extensivly and we found no problem at all debugging the code, Using TestDriven.NET and TypeMock. If you can send an example of when this happens, I would like to know.
Saturday, May 27, 2006 6:38 AM by mattonsoftware.com

# .NET Resources

The following links to .NET resources have been collated over time with the assistance of colleagues. ...
Saturday, November 17, 2007 4:53 PM by Community Blogs

# Mocking LINQ Queries, Extension methods and Anonymous Types

One of the things I wanted to show at my Interactive session on unit testing tips and tricks at TechEd