Suppose, I have a class SomeClass
with a method void process()
. The implementation of this method is smth like new Thread(this::someOtherMethod).start
(need to execute only someOtherMethod
in a particular thread).
Having written down a unit test for this method:
SomeClass class= new SomeClass(anObjectToWorkWith);
class.process();
assertEquals(expectedObj, anObjectToWorkWith)
I have realised, that as the process
method executes in a particular thread, an assertEquals
instruction is called before the process
method is completed.
Therefore, I have a question: is there some way to wait for the process
method execution, to make assertEquals
be called necessarily after the process
.
Thank you in advance.
P.S. Don't propose solutions that use Thread.sleep
method or solutions that imply making SomeClass
implement Runnable
interface, as these solutions don't conform to the tasking.