Reputation: 2570
I have a system that relies heavily on network IO requests. I'd like to make a reliable performance test. One naive way could be to put the thread to sleep for some time.
My question is if the fact that I'm putting a thread to sleep is equal to a thread being blocked on an HTTP request?
I'm asking it with a perspective of Thread Lifecycle. Theoretically speaking, if an HTTP request would take a constant and known amount of time, would that be equal to a Thread.sleep?
In other words, would test results be the same? (To some extent of course, since scheduling is considered indeterministic)
Upvotes: 0
Views: 1031
Reputation: 3612
It's a bad practice to use Thread sleep in order to simulate http calls. It's much better to use real http calls. If you can't send real http requests to remote services you can simulate these services using wiremock
Upvotes: 1
Reputation: 6816
It is not so clear what you are trying to test here.
Generally speaking, using Thread.sleep()
is not a good practice in tests.
If you are testing your application, then you should mock the other endpoint that you are calling using a mock server.
Upvotes: 1