Is TypeMock Isolator: WillThrow () expiring across unit test boundaries?

I have two unit tests that use TypeMock Isolator to isolate and fake a method from asp.net SqlMembershipProvider.

In test 1, I have:

Isolate.WhenCalled( () => Membership.CreateUser(...))) .WithExactArguments() .WillThrow(new Exception()); 

In test 2, I have:

  Isolate.WhenCalled( () => Membership.CreateUser(...))) .WithExactArguments() .WillReturn(new MembershipUser(...)); 

When I run each test on its own, they both pass successfully.

When I run both tests, test number 1 starts first and passes and then tests number 2 and fails with the exception caused by test 1.

Why did the WillThrow() command in test 1 bleed for test 2? After all, test 2 explicitly defines a different behavior - WillReturn() ?

+7
c # unit-testing typemock typemock-isolator
source share
1 answer

If TypeMock's behavior is bleeding between tests, then the first thing to check is cleaning between tests. You can do this explicitly by calling Isolater.CleanUp() or using the preferred approach , which should decorate either the testing methods or the test class itself with the [Isolated] attribute.

+6
source share

All Articles