Eric Dand
Eric Dand

Reputation: 1210

NUnit throws System.InvalidOperationException: "All test threads are blocked."

Today I went to run my NUnit tests, and found suddenly that a ton were failing! The cause of nearly all failures was the same:

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.InvalidOperationException : All test threads are blocked. Did you start new threads that the test doesn't know about?

When I Googled this exception, I found no reference of it in relation to NUnit. Has anyone seen this before?

Upvotes: 0

Views: 1156

Answers (2)

Eric Dand
Eric Dand

Reputation: 1210

I figured it out!

I had made a change which resulted in a whole lot of tests stuck waiting forever for something which never happened. This manifested itself in some tests as hanging forever, and in the remainder as raising the aforementioned InvalidOperationException.

So, in brief, when a lot of your tests hang forever and NUnit tries to parallelize testing, it runs out of threads and complains.

I originally posted this question not because my tests were failing, but because there were no resources out there when I Googled the mysterious exception. Hopefully this answer can help someone else who is mystified by this error in the future.

Upvotes: 1

Ryan Chu
Ryan Chu

Reputation: 1547

Hope I can comment below, but anyways, which NUnit adapter are you using?

Found an issue reported with NUnit adapter 3.0.0.0

enter image description here

Upvotes: 2

Related Questions