I have an eventsystem, which I want to test using integration tests. Normally, this works quite well: I do something, and I receive an event.
In the past, we had some problems with events which arrived late. This makes the test duration unpredictible long - but still ok.
But sometimes, I want to test that an event doesn't arrive. With this scenario, I only see a way to do the action and then wait at lest 30 seconds - a time limit which is normally enough for events to arrive.
The method for getting the events runs asynchronously using a Future.
Now, I think the question is clear: how can I implement such a test scenaraio without blocking the whole test suite by 30 seconds. I see the following options:
- Use parallelization of Junit. Actually, I'm already doing this, but too much parallelization increases the chance that single test times out.
- Is it possible to finish the test method by leaving a Future open and change the test status in delayed from inside this Future? Whis would allow Junit to allow another test in the background and wait some extra time (maybe even a minute)
Doesn't matter if Junit 4 or 5
Aucun commentaire:
Enregistrer un commentaire