I have a JUnit test case where I’m expecting a particular method call to take a long time (over a minute). I want to
- Make the method call.
- Make sure the method call takes at least a minute and have a JUnit assertion fail if it doesn’t.
- Then kill the method call (assuming it took more than a minute as it should) because it could take a really long time.
How do I do this?
You can write a class implementing runnable that wraps around the method of interest; assuming spawning threads is allowed.
Then in your JUnit you can do something like: