gpt4 book ai didi

JUnit 5——全局超时?

转载 作者:行者123 更新时间:2023-12-02 07:54:32 24 4
gpt4 key购买 nike

在 JUnit 5 中,对所有测试强制执行全局超时的最佳方法是什么?

我发现 JUnit 4 有一个 @Rule 功能,但该功能已在 JUnit 5 中删除。我不想复制粘贴 assertTimeoutPreemptively对于每个测试。

最佳答案

Junit 5.5 确实支持“全局超时”。看看documentation of corresponding property knobs .

例如,尝试打开文件 src/test/resources/junit-platform.properties 并粘贴到此处:

junit.jupiter.execution.timeout.default=42 ms

关于JUnit 5——全局超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47041313/

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