[英]Why am I facing issue with junit 5 assertThrows for asserting TimedOutException despite passing expected parameters?
您可能导入并使用了错误的 class(来自 JUnit 4 而不是 JUnit 5)
In JUnit 5 please use only org.junit.jupiter.api.Assertions
instead of org.junit.Assert
.
As you mentioned in a comment that you imported org.unit.Assert
: This is the utility with the static assertions from JUnit 4, not JUnit 5. It provides a method assertThrows
, but with different parameters, and is not upwards compatible with JUnit 5 . 通常你会在注释的帮助下期待 JUnit 4 中的异常。
您可以在 JUnit 5 的API 文档中找到有关方法参数的详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.