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
Here's a very simple use case:

public void Failure()
    // Do stuff
    Assert.IsTrue( false );

I'm using the latest TypeMock, NUnit 2.5.8 and TestDriven 3. With the test fixture NOT marked as Isolated, I get the following result:

Test 'TypeMock.Tests.Failure' failed: 
  Expected: True
  But was:  False
   Tests.cs(199,0): at TypeMock.Tests.Failure()

If however I mark the class Isolated, I see the following:

Test 'TypeMock.Tests.Failure' failed: 
  Expected: True
  But was:  False
   at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
   at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
   Tests.cs(0,0): at TypeMock.Tests.Failure()

Sometimes, the last line would have a line number, e.g. Tests.cs(190,0), but pointing to the method start, not the actual failing line. In the example above it just goes to the first line in the file.

I'm seeing the same behavior in the NUnit GUI (run via TMockRunner). Is this a bug?
asked by roman (2.2k points)

2 Answers

0 votes
Hello Roman,

Hmm, this looks like a bug. Isolated attribute causes the test method to be executed with a post-execution cleanup operation. If an exception occurs (such as the Assert exception), we trim the call stack a little bit not to expose too much noise. Perhaps somewhere the line number got screwed up.

Thanks for the heads-up, I'll check it out and get back to you!
answered by igal (5.7k points)
0 votes

I've just noticed, you are using a namespace called "Typemock".
This is a known issue - Isolator avoids faking itself (also) by checking the assembly name against "Typemock"...

MyTypemockTests.Tests.Failure should work better...


Yonatan Eldar,
TypeMock Support Group
answered by yonatan (1.6k points)