Write better tests with

ScalaMock

1 2 3 4 5 6 7 8 9 10 11 12
"drawLine" should "interact with Turtle" in {
  // Create mock Turtle object
  val mockedTurtle = mock[Turtle]
 
  // Set expectations
  (mockedTurtle.setPosition _).expects(10.0, 10.0)
  (mockedTurtle.forward _).expects(5.0)
  (mockedTurtle.getPosition _).expects().returning(15.0, 10.0)
 
  // Exercise System Under Test
  drawLine(mockedTurtle, (10.0, 10.0), (15.0, 10.0))
}

Simple yet powerful

ScalaMock has very clean and concise syntax, reasonable defaults, powerful features and is fully type-safe.

Full Scala support

Full support for Scala features such as: Polymorphic methods, Operators, Overloaded methods, Type constraints, and more.

ScalaTest and Specs2 integration

ScalaMock can be easily used in ScalaTest and Specs2 testing frameworks.