gpt4 book ai didi

运行测试脚本时出现 java.util.concurrent.TimeoutException

转载 作者:行者123 更新时间:2023-12-02 01:20:53 35 4
gpt4 key购买 nike

我在使用 vert.x Flamework(版本:“3.8.1”)时遇到一些问题。我在运行单元测试时遇到了 java.util.concurrent.TimeoutException 。没有什么会阻塞线程。我对此感到困惑。

TestMainVerticle.java


@ExtendWith(VertxExtension.class)
public class TestMainVerticle {

@BeforeEach
void deploy_verticle(Vertx vertx, VertxTestContext testContext) {
vertx.deployVerticle(new MainVerticle(), testContext.succeeding(id -> testContext.completeNow()));
}

@Test
void verticle_deployed(Vertx vertx, VertxTestContext testContext) throws Throwable {
testContext.completeNow();
}
}

主垂直

public class MainVerticle extends AbstractVerticle {


@Override
public void start(Promise<Void> startPromise) throws Exception {

}
}

输出


The test execution timed out. Make sure your asynchronous code includes calls to either VertxTestContext#completeNow(), VertxTestContext#failNow() or Checkpoint#flag()
java.util.concurrent.TimeoutException: The test execution timed out. Make sure your asynchronous code includes calls to either VertxTestContext#completeNow(), VertxTestContext#failNow() or Checkpoint#flag()
at io.vertx.junit5.VertxExtension.joinActiveTestContexts(VertxExtension.java:230)
at io.vertx.junit5.VertxExtension.beforeTestExecution(VertxExtension.java:191)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeTestExecutionCallbacks$5(TestMethodTestDescriptor.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:169)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeTestExecutionCallbacks(TestMethodTestDescriptor.java:154)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:125)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
...

最佳答案

如果 promise 未完成,Verticle 部署永远不会完成:

public class MainVerticle extends AbstractVerticle {


@Override
public void start(Promise<Void> startPromise) throws Exception {
// Complete the promise when the verticle is ready
startPromise.complete();
}
}

关于运行测试脚本时出现 java.util.concurrent.TimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57726876/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com