vb.net - How to force specific Visual Basic .NET unit test to run serially -
when configuring tests run in parallel, such using resharper, there seems no way flag specific unit test class run serially.
an example of class requires 1 deletes/recreates data before each indiviual test (from database or file structures).
if parallel test runs start, can hit mytestinitialize() @ point, leads chaos other tests in middle of asserting various conditions.
a way in visual studio 2010 seems to create class single shared object can locked when mytestintialize() called , unlocked when mytestcleapup() called.
eg
' prevent resharper running tests in parallel public class singleprocess public shared lock new object end class '..... <testclass()> _ public class mytestclass <testinitialize()> _ public sub mytestinitialize() threading.monitor.enter(singleprocess.lock) ' initialize stuff end sub ' <testcleanup()> _ public sub mytestcleanup() ' release lock threading.monitor.exit(singleprocess.lock) end sub
Comments
Post a Comment