GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dvic/ScalaMock: Native Scala mocking framework

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

409 Commits
409 Commits

Folders and files

NameName
Last commit message
Last commit date
core/src/main/scala/org/scalamock
core/src/main/scala/org/scalamock
 
 
core_tests/src
core_tests/src
 
 
examples/src
examples/src
 
 
frameworks
frameworks
 
 
project
project
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
README.md
README.md
 
 
RELEASE_NOTES.md
RELEASE_NOTES.md
 
 
ScalaMock.sublime-project
ScalaMock.sublime-project
 
 
rootdoc.txt
rootdoc.txt
 
 

Repository files navigation

ScalaMock Build Status

Native Scala mocking.

Official website: http://scalamock.org/

Examples

Expectations-First Style

def testTurtle {
  val m = mock[Turtle]                              // Create mock Turtle object

  (m.setPosition _).expects(10.0, 10.0)             //
  (m.forward _).expects(5.0)                        // Set expectations
  (m.getPosition _).expects().returning(15.0, 10.0) // 

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

Record-then-Verify (Mockito) Style

def testTurtle {
  val m = stub[Turtle]                              // Create stub Turtle
  
  (m.getPosition _).when().returns(15.0, 10.0)      // Setup return values

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

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

Full worked example

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

Downloading

Download from Sonatype.

To use ScalaMock in sbt with ScalaTest add the following to your project file:

libraryDependencies +=
  "org.scalamock" %% "scalamock-scalatest-support" % "3.2.2" % "test"

and with Specs2:

libraryDependencies +=
  "org.scalamock" %% "scalamock-specs2-support" % "3.2.2" % "test"

Documentation

  • Quick Start
  • User Guide
  • Scaladoc

Future Plans

Check our roadmap.

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.

About

Native Scala mocking framework

scalamock.org/

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.