我有一个非常简单的测试,我试图模仿一个特点。测试甚至没有运行,并且由于初始化错误而失败:java.lang.IllegalArgumentException:要求失败:您记得使用withExpectations?吗?
以下是我非常简单的测试:
import org.scalatest._
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.matchers.ShouldMatchers
import org.scalamock.ProxyMockFactory
import org.scalamock.scalatest.MockFactory
@RunWith(classOf[JUnitRunner])
class TurtleSpec extends FunSpec with MockFactory with ProxyMockFactory {
trait Turtle {
def turn(angle: Double)
}
val m = mock[Turtle]
m expects 'turn withArgs (10.0)
describe("A turtle-tester") {
it("should test the turtle") {
m.turn(10.0)
}
}
}发布于 2013-06-25 15:51:20
在运行测试之前,需要调用resetMocks / resetExpectations,最好的方法是(ScalaTest方法):
class TurtleSpec extends FunSpec with MockFactory with ProxyMockFactory with BeforeAndAfter {
before {
resetMocks()
resetExpectations()
}
...
}https://stackoverflow.com/questions/14283879
复制相似问题