我经常需要在我的 devKit 连接器中等待一些异步进程完成(然后导致 isConnected 返回 true )
@ValidateConnection
public boolean isConnected() {
return isConnected;
}
我怎样才能让我的功能单元测试等到完成。我原以为单元测试会等到我的流程中的所有连接器都“连接”起来。
Atm 我在单元测试中使用睡眠来解决我的 FunctionalTestCase
Thread.sleep(5000);
assertEquals(1, targetEngineApplication.getNumberOfMessagesReveived());
编辑_ _ __ _ __ _ __ _ __ _ __ _ ____
连接代码:
@Connect
public void connectMethod(final String configFileLocation) throws ConnectionException {
System.out.println("Connect called with config:" + configFileLocation);
try {
Engine.doInitialise(configFileLocation);
Engine.doStart();
} catch (InitialisationException e) {
throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, "0", e.getCause().getMessage(), e);
} catch (StartingException e) {
throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, "0", e.getCause().getMessage(), e);
}
// this will also tell the unit tests to start
isConnected = true;
}