prevent vstest discovery engine locking DLLs

前端 未结 2 678
醉话见心
醉话见心 2021-02-18 16:15

I have some C# unit tests for a VS2012 project which calls a VS2010 c++ DLL using DllImport pinvoke.

As a pre-build event for the test project, I copy the latest versio

2条回答
  •  半阙折子戏
    2021-02-18 16:44

    I recently also had this issue and the problem was caused by my own user code.

    During test discovery all the test classes are instantiated and in one of our test class constructors, a quite complex business classes was initialized. The problem is that during initialization of it a background thread was created, that did the following:

    socket.Read(...)
    

    This thread kept running forever waiting for some socket data to arrive and as a result locked our assembly.

    So the solution for me was to make sure this code won't get called during test discovery.

    You can check, if you are affected by this issue, by attaching Visual Studio to the test discovery engine when it has locked some assembly. After pressing pause you normally will see, that the current executing line is somewhere in your own user code (also check the Threads window).

提交回复
热议问题