Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing Scala中的验证测试_Unit Testing_Scala_Testng_Verification_Mockito - Fatal编程技术网

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,不幸的是,它没有改变任何东西