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
Is there a routine I can in TypeMock Isolator to "cleanup" after a unit test? I'm having problems w/ some unit tests passing when run individually, but failing when run together with an exception like this:

Test method UnitTestNameHere threw exception:
TypeMock.TypeMockException:
*** Static constructor for class Log cannot be faked as it has already been called

I'm guessing that a fake call I did in a prior unit test is interfering with this unit test.
asked by sorakiu (4.2k points)

16 Answers

0 votes
Hi,

We fixed the bug, I sent you an email with the link to download it.
Please check it out and let me know if it solves the problem.


I haven't received the link yet -- can you send it again?
answered by sorakiu (4.2k points)
0 votes
Done :)
answered by ohad (35.5k points)
0 votes
I installed it and tried it on a test where I had an Isolate.FakeStaticMethods(typeof(Log)) and then in another test, something I hadn't mocked at all, a class called Resources was acting as if it was mocked. I tried to step into the code and I saw this in the output log:
Step into: Stepping over method without symbols 'TypeMock.InternalMockManager.isMocked'


Nowhere in my code have I mocked the Resources class at all.

Is there perhaps a separate issue?
answered by sorakiu (4.2k points)
0 votes
Hi,

Just making sure - are all decrated with [Isolated]? Test not marked as [Isolated] doesn't not cleanup when it's finished.

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Am I supposed to mark the test? or the class?

My test class looks like:
    [TestClass(),Isolated]
    public class XXTest
    {
        [TestMethod()]
        public void SendRequestAndReceiveResponseTest()
        {
        ...
        }
        [TestMethod()]
        public void SendRequestAndReceiveResponseNullTest()
        {
        ...
        }
    }
answered by sorakiu (4.2k points)
0 votes
Hi,

If you use the the Isolated attribute in the class level it will apply to all test methods so in your case you used it correctly.
Can you please post here the tests code so we can reproduce the problem?
answered by ohad (35.5k points)
...