相关疑难解决方法(0)

如何在Scala中使用JUnit ExpectedException?

我希望能够在Scala中使用JUnit 4.7的ExpectedException @Rule.但是,似乎没有任何东西:

import org.junit._

class ExceptionsHappen {

  @Rule 
  def thrown = rules.ExpectedException.none

  @Test
  def badInt: Unit = {
    thrown.expect(classOf[NumberFormatException])
    Integer.parseInt("one")
  }
}
Run Code Online (Sandbox Code Playgroud)

这仍然失败了NumberFormatException.

junit scala exception

6
推荐指数
2
解决办法
1715
查看次数

标签 统计

exception ×1

junit ×1

scala ×1