Unit testing Scala中的验证测试
我想在我的测试中做一些验证,但它从来没有失败过Unit testing Scala中的验证测试,unit-testing,scala,testng,verification,mockito,Unit Testing,Scala,Testng,Verification,Mockito,我想在我的测试中做一些验证,但它从来没有失败过 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 simpl
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测试运行。我错在哪里?规范似乎不支持使用TestNG运行测试:您可以做的一件事是将您的测试编写为TestNG测试,并使用specs2特性进行更好的匹配/模拟:@Eric,支持TestNG有什么问题吗?或者它还没有完成?我模糊地记得在模拟断言之后需要进行某种断言。尝试在
有一个(t).bar()
之后放置一个断言(true)
,看看这是否改变了什么。@Daniel C.Sobral,不幸的是,它没有改变任何东西