views:

46

answers:

1

I have a "black box" of code that contains many threads. There is no method to "kill" the black box threads that I have found.

I am passing data into the "black box" through junit and making sure that I am getting the expected outputs.

Is there a way to gracefully exit the test case (It keeps it open in eclipse because of the threads in the black box)?

+3  A: 

In very short, no. A JUnit way to handle this is to abstract the thread creation and pass in a fake one under test.

JUnit is really about white-box testing, not black box testing of multiple threads. It could be done, of course, but issues like this are going to be painful. Fortunately, there are libraries out there that can help with this problem. One such library is ConcoJUnit.

Yishai