In some of my integration tests I start multiple threads and wanted to ensure that when the integration test finishes (even if it fails) the thread will be cleaned up. Can anyone recommend an elegant way to do this?
Thanks
EDIT: Thanks for everyone’s answers – just to clarify, ‘cleaned up’ was referring to when the testing threads stops and some of the other threads in a test haven’t QTAgent (the testing process) was giving an error.
Threadobject for every thread you createThread.Join()on all of them at the end of the test, after setting appropriate termination signals. If any thread doesn’t terminate quickly enough, this should cause the test to fail even if the test would otherwise have passed.It’s impossible to answer this in more detail without knowing more about your application and test architecture.