Tuesday, August 03, 2010

Statics 'r Bad, M'kay

Particularly in unit tests - since unit tests are run in the same AppDomain (at least with MSTest), the value of the static is preserved across tests.

This can have unintended side effects that are difficult to debug such as a unit tests passing in isolation and failing when run as a group, tests passing or failing when run in a different order, etc. Sometimes, poor design choices make this unavoidable - be aware of this consequence of using statics and make sure to reset your statics in the TestCleanup event!

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

<< Home