jjzjj

exampleRoom

全部标签

java - Junit/Mockito - 等待方法执行

在我的应用程序中,我对某些操作使用了观察者模式,我想在单元测试中测试它们。问题是我不知道如何使用junit/mockito/其他东西测试观察者。有帮助吗?例如这是我的单元测试:@BeforepublicvoidsetUp()throwsIOException,Exception{observer=newGameInstanceObserver();//observable(GameInstance)willcallupdate()methodaftereverychangeGameInstance.getInstance().addObserver(observer);//thisis