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 have a unit test that does an ExpectAndThrow so that I can unit test my exception handling.

When I execute the test by itself, it passes - the exception is thrown, and the enterprise library logging writes the error log to the database.

When I execute the test with all of my other unit tests (or just one other test, for that matter), the exception is thrown - but I get an ExceptionHandling exception (object reference not set to an instance of an object).

I do not understand why I am getting different behavior simply based on whether or not the test is executed by itself vs. with others.

Has anyone else encountered this issue?
asked by csustek (4k points)

2 Answers

0 votes
Hi,
This can happen when a mock from a previous test is affecting your test.
To make sure this doesn't happen use MockManager.ClearAll(); in your TearDown method.
:idea: You can also analysis this case using the TypeMock Tracer Utility.
If this doesn't help please tell us and we will analysis the TypeMock logs.
answered by scott (32k points)
0 votes
Hi,
This can happen when a mock from a previous test is affecting your test.
To make sure this doesn't happen use MockManager.ClearAll(); in your TearDown method.
:idea: You can also analysis this case using the TypeMock Tracer Utility.
If this doesn't help please tell us and we will analysis the TypeMock logs.


This was the problem. Darn static objects.
answered by csustek (4k points)
...