Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

Can not call Swap.AllInstances() more than once on a type

+1 vote
We have coded a handful of tests, some of which use the TypeMock.Isolator.VisualBasic SwapAllInstances method. When running the tests that use SwapAllInstances individually, either the tests pass, or a different error is generated (differing for each test). When all tests are ran, the error "Can not call Swap.AllInstances() more than once on a type" is generated. Is there an issue with running multiple tests that use the SwapAllInstances Function?
asked Nov 17, 2009 by jdivis (380 points)

2 Answers

+1 vote

Do your tests have the [Isolated] attribute? This should ensure behavior is cleaned up between tests, allowing you to declare Swap.AllInstances() again. If this doesn't help, can you post your tests here (or send them to our support email)? I'm also interested in trying to help out with the tests that fail individually.

Typemock Support
answered Nov 17, 2009 by doron (26,680 points)
+3 votes

Thank you for the suggestion. Just got back to these Unit Tests, tried your Isolated() attribute and that solved the swapallinstances issue.

I was able to resolve the other issues with the tests that were being masked by the "Can not call Swap.AllInstances() more than once on a type" error.

Thank you,

answered Nov 25, 2009 by jdivis (380 points)