我希望能够在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.