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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Hi

In my solution I have a range of green unit tests (none of the are using TypeMock). When I add a new unit test using TypeMock (I am evaluating TypeMock at the moment) and run all test (Ctrl+R, A) most of my other unit test (that runs after my new unit test) fails!??

The new unit test I am adding is by no means finish yet - but I get the error by just having this one line in my test:

  <TestMethod> _
  <Isolated> _
  Public Sub SaveSiteToVP2009Test()

    ' Arrange
    ' -------
    Dim fakeDB = FakeInstance(Of DataAccessAdapter)()

  end sub


The errors I get in the following unit tests are releated to "DataAccessAdapter". It seems that this line throws a "Object reference not set to an instance of an object" exception:

        Dim _adapter As New DataAccessAdapter()



If I change my new unit test to this (comment/removing TypeMock stuff):

  <TestMethod> _
  <Isolated> _
  Public Sub SaveSiteToVP2009Test()

    ' Arrange
    ' -------
    ' Dim fakeDB = FakeInstance(Of DataAccessAdapter)() 

  end sub



My other unit test goes green (runs fine).


What am I doing wrong?!

And one other thing: If I finish my new unit test and run all the test (including my new TypeMocked unit test) one at the time everything is green (fine).
asked by Mikael (1.2k points)

4 Answers

0 votes
this does seem weird, especially since there are no behaviors set on on any object.

can you try putting the <Isolated> attribute on the class holding the tests instead of on the test itself and write down what is the result?

also,
can you send a simple test project that shows this behavior to support@typemock.com?

what version of Isolator are you using?

Do you happen to have Racer installed as well?

what version of windows are you using?
answered by royo (2k points)
0 votes
I think the problem has something to do with the DataAccessAdapter constructor. It uses a singleton object. Somehow this singleton is not valid in the next unit test. I guess that faking the DataAccessAdapter also results in an invalid singleton and that’s the reason why many of the following unit test fails. :(

I am not able to create a simple project that gives the error. My application uses LLBL Pro and the adapter is part of the LLBL Pro framework.

I am using version TypeMock Isolator 5.3
Racer is not used and I am running Vista.
answered by Mikael (1.2k points)
0 votes
Hi Mikael,

You can still send a project that show this issue - we can test using LLBL.

In the meantime try to change the FakeInstance method:
Dim fakeDB = FakeInstance(Of DataAccessAdapter)(Members.CallOriginal) 


This should initialize the singleton to properly and should enable the tests to work
answered by dhelper (11.9k points)
0 votes
Thank you!


By using your code:
  Dim fakeDB = FakeInstance(Of DataAccessAdapter)(Members.CallOriginal)


..all my unit tests are now green again 8)
answered by Mikael (1.2k points)
...