-3

If I have a test case as follows

TEST(one, test_one) {
    vector<thread> threads
    // ... initialize threads
}

and somewhere in those threads an assertion fails, how do I stop all threads and terminate? because it seems like the function keeps executing as of now..

Curious
  • 20,870
  • 8
  • 61
  • 146

1 Answers1

1

how do I stop all threads and terminate?

It can't be done without interactions from your class under test, and the threads it involves actually.

If you have some class under test, that involves running multiple threads, you should have some implementation in the destructor, to signal threads to stop and join them.


Though I could think about something along the lines of a death test bailing out from an expected assert() statement, and the whole process is killed (hence no need to worry about other threads being terminated).

Community
  • 1
  • 1
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190