I assume that you might have made your mocking code and you might want to do a simple integration test to make sure your call to the server works.
One of the difficulties in testing threads comes from their very nature - they are parallel. This means that you are forced to write JUnit test code, which is forced to wait until your thread completes its work before testing the results of your code. This is not a good way to test the code and may be unreliable, but usually it means that you have an idea of ββwhether the code is working.
As an example, your code might look something like this:
@Test public void myIntegrationTest() throws Exception {
I really don't like to do this and prefer ridicule and agree with the other answers. But if you need to check your threads, then this is one of the approaches that I find.
roghughe
source share