【发布时间】:2011-09-18 18:38:28
【问题描述】:
我想在我的测试中做一些验证,但它永远不会失败
import org.testng.annotations.Test
import org.specs.Specification
import org.specs.mock.Mockito
import org.mockito.Matchers._
class Tests extends Specification with Mockito{
class Foo {
def bar(){}
}
@Test def simplestTest() {
val t = mock[Foo]
t.bar()
there was one(t).bar() //pass
}
@Test def simplestFailTest() {
val t = mock[Foo]
there was one(t).bar() //pass
}
@Test def testFail() {
assert(false) //fails
}
}
我将它作为 TestNG 测试运行。我哪里错了?
【问题讨论】:
-
我模糊记得在模拟断言之后需要进行某种断言。尝试在
there was one(t).bar()之后添加assert(true),看看是否有任何改变。 -
@Daniel C. Sobral,不幸的是它没有改变任何东西
标签: unit-testing scala testng verification mockito