Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET unit test framework that can handle tests with more than one thread

I'm trying to find a unit test framework, for the .NET platform, that can handle tests with more than one thread.

NUnit does not supports tests that spanws threads, since, for example, exceptions in those threads are not taked into consideration. There is an extension by Roy Osherove, but it is quite dated 1.

MBUnit allows a test to be concurrently executed by many threads, however I don't know if it supports threads that are created inside a thread. For instance, to test a concurrent collection, I want different kinds of threads (producer threads and consumer threads) running simultaneous. Having multiple threads executing the same test code is not enough.

Thanks Pedro

like image 420
Pedro Felix Avatar asked Sep 10 '10 21:09

Pedro Felix


People also ask

What is multi threaded testing?

Multithread testing: Multithreaded testing is where concurrent transactions of an application are running at the same time. It can run on a single machine or distribute across multiple machines.

What is the best unit testing framework for .NET core?

xUnit test is the best Unit testing framework for . Net programming languages like C#, VB.Net, and F#. xUnit derives its structure and functionality from SUnit of Smalltalk.

Does junit use multiple threads?

4.1 concurrent-junitConcurrent-junit library helps the users to test the methods for multi threading. It will create threads for testing methods. By default, number of threads created by this library is 4, but we can set the desired number of threads.

How do you test multithreading?

To test multi-thread functionality, let the multiple instances of the application or program to be tested be active at the same time. Run the multi-thread program on different hardware. Thread testing is a form of session testing for which sessions are formed of threads.


1 Answers

I am assuming that your main issue is that exceptions that do not happen on the "test thread" (i.e. the main thread) do not result in test failure.

The fact that these exceptions are ignored can be controlled somewhat. I explain this issue in a blog post in terms of the ReSharper test runner, but the same fix applies to the NUnit runner:

ReSharper test runner – hidden thread exceptions

The key is configuring legacyUnhandledExceptionPolicy for the executable that is running the tests.

like image 102
Tim Lloyd Avatar answered Nov 02 '22 19:11

Tim Lloyd