ScalaMock Specs2 Support


License

License

MIT
Categories

Categories

Scala Languages
GroupId

GroupId

org.scalamock
ArtifactId

ArtifactId

scalamock-specs2-support_2.11
Last Version

Last Version

3.6.0
Release Date

Release Date

Type

Type

jar
Description

Description

ScalaMock Specs2 Support
ScalaMock Specs2 Support
Project URL

Project URL

http://scalamock.org/
Project Organization

Project Organization

org.scalamock
Source Code Management

Source Code Management

https://github.com/paulbutcher/ScalaMock

Download scalamock-specs2-support_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/org.scalamock/scalamock-specs2-support_2.11/ -->
<dependency>
    <groupId>org.scalamock</groupId>
    <artifactId>scalamock-specs2-support_2.11</artifactId>
    <version>3.6.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.scalamock/scalamock-specs2-support_2.11/
implementation 'org.scalamock:scalamock-specs2-support_2.11:3.6.0'
// https://jarcasting.com/artifacts/org.scalamock/scalamock-specs2-support_2.11/
implementation ("org.scalamock:scalamock-specs2-support_2.11:3.6.0")
'org.scalamock:scalamock-specs2-support_2.11:jar:3.6.0'
<dependency org="org.scalamock" name="scalamock-specs2-support_2.11" rev="3.6.0">
  <artifact name="scalamock-specs2-support_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scalamock', module='scalamock-specs2-support_2.11', version='3.6.0')
)
libraryDependencies += "org.scalamock" % "scalamock-specs2-support_2.11" % "3.6.0"
[org.scalamock/scalamock-specs2-support_2.11 "3.6.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.8
org.scalamock : scalamock-core_2.11 jar 3.6.0
org.specs2 : specs2-core_2.11 jar 3.8.6

Project Modules

There are no modules declared in this project.

ScalaMock

Native Scala mocking.

Official website: scalamock.org

Examples

Expectations-First Style

test("drawline interaction with turtle") {
  // Create mock Turtle object
  val m = mock[Turtle]
  
  // Set expectations
  (m.setPosition _).expects(10.0, 10.0)
  (m.forward _).expects(5.0)
  (m.getPosition _).expects().returning(15.0, 10.0)

  // Exercise System Under Test
  drawLine(m, (10.0, 10.0), (15.0, 10.0))
}

Record-then-Verify (Mockito) Style

test("drawline interaction with turtle") {
  // Create stub Turtle
  val m = stub[Turtle]
  
  // Setup return values
  (m.getPosition _).when().returns(15.0, 10.0)

  // Exercise System Under Test
  drawLine(m, (10.0, 10.0), (15.0, 10.0))

  // Verify expectations met
  (m.setPosition _).verify(10.0, 10.0)
  (m.forward _).verify(5.0)
}

A more complete example is on our Quickstart page.

Features

  • Fully typesafe
  • Full support for Scala features such as:
    • Polymorphic (type parameterised) methods
    • Operators (methods with symbolic names)
    • Overloaded methods
    • Type constraints
  • ScalaTest and Specs2 integration
  • Mock and Stub support
  • Macro Mocks and JVM Proxy Mocks
  • Scala.js support
  • built for Scala 2.11, 2.12, 2.13
  • Scala 2.10 support up to ScalaMock 4.2.0

Using ScalaMock

Artefacts are published to Maven Central and Sonatype OSS.

For ScalaTest, to use ScalaMock in your Tests, add the following to your build.sbt:

libraryDependencies += Seq("org.scalamock" %% "scalamock" % "5.0.0" % Test,
    "org.scalatest" %% "scalatest" % "3.2.0" % Test)

Documentation

For usage in Maven or Gradle, integration with Specs2, and more example examples see the User Guide

Donations

This project is run for fun as a hobby, but if you want to show your appreciation you can donate some ETH or tokens to 0x6A34A63dbD851e4BEC2D25eC7d4E7b50e213C3A7 (QR Code). Or other crypto currencies (Bitcoin, etc) via Changelly here. If you want to learn more about Ethereum, visit the homepage or wikipedia.

Acknowledgements

YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: YourKit Java Profiler and YourKit .NET Profiler.

Many thanks to Jetbrains for providing us with an OSS licence for their fine development tools such as IntelliJ IDEA.

Also, thanks to https://github.com/fthomas/scala-steward we are keeping dependencies updated automatically, and to https://travis-ci.org/ running CI/CD automatically for every commit and PR.

Versions

Version
3.6.0
3.5.0
3.4.2
3.4.1
3.3.0
3.2.2
3.2.1
3.2
3.2-RC1
3.1.4
3.1.2
3.1.1