Want to create a unit test for android library project. I need to test if the given thread is waiting (synchronized object.wait() was called) or not. Is it possible to determine it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A common way to write unit tests to see if a method is called is to create a mock object that overrides the method to check and sets a flag when it is called. For example:
Substitute the use of your class for this mock and then check that
assertTrue(mockClass.mWaitWasCalled)Given a random object, there’s no way to tell if a thread is waiting on it.