- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下测试类:
import org.scalatest.FunSuite
@RunWith(classOf[JUnitRunner])
class NodeScalaSuite extends FunSuite {
test("Now doesn't terminate future that's not done") {
val testFuture: Future[Int] = Future{
wait(1000)
10
}
assertThrows[NoSuchElementException]{
testFuture.now
}
}
not found: value assertThrows
最佳答案
我也刚遇到这个问题 - 但正如评论中提到的,这取决于我使用的 scala 测试版本。 assertThrows
直到 2.2.6 之后才引入 - 升级到 3.0.0(如果可以)将使其成为可能:请参阅此处引用文档的旧版本:http://doc.scalatest.org/2.2.6/#org.scalatest.FunSuite
如果你不能升级,之前断言异常的方法是使用 intercept
方法:
test("Invoking head on an empty Set should produce NoSuchElementException") {
intercept[NoSuchElementException] {
Set.empty.head
}
}
关于scala - 未找到 : value assertThrows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39194331/
谁能告诉我如何使用 assertThrows 有几个异常(exception)? 例如,这是一个类: protected void checkViolation(Set> vViolations)
我有以下测试类: import org.scalatest.FunSuite @RunWith(classOf[JUnitRunner]) class NodeScalaSuite extends F
我昨天开始学习 Scala,所以我对它还很陌生。学习一门新语言时我喜欢做的一件事是尝试创建一个微型 TDD 库。 这是我到目前为止得到的: def assert(condition: Boolean,
任何人都有一个或两个指向“STAssertThrows”的IOS / OCUnit文档的链接 API doco +如何使用示例 最佳答案 Here are the docs. 用法很简单,说您有方法
所以我正在编写单元测试,在其中测试将用户列入黑名单和取消黑名单的功能(这是我代码中的一个功能,它本身运行良好)。 这是一个按预期工作的示例命令: assertThrows(ExecutionExcep
我们如何使用应该抛出异常的 MockWebServer 测试挂起函数? fun `Given Server down, should return 500 error`()= testCoroutin
使用 Java 和 assertThrows 时: public static T assertThrows(Class expectedType, Executable executable) 我
我正在使用JUnit 5库,我尝试使用assertThrows并获取抛出的异常,以便获取异常的消息。我有这样一段代码: import org.junit.jupiter.api.Assertions;
我正在努力学习本教程 JUnit 5: How to assert an exception is thrown? 我使用 Java 10、IntelliJ 2018 和 Junit 5。 我制作了一
我正在使用 JUnit 4.12 pl.pragmatists JUnitParams 1.0.5 test 我想知道最推荐使用哪一个@Test(expected
我是一名优秀的程序员,十分优秀!