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
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With