Skip to content

Example for ACM 2019 Scala Symposium paper Tests as Maintainable Assets Via Auto-generated Spies

Notifications You must be signed in to change notification settings

klaeufer/issue10709-scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Quality Gate Status

This issue has been fixed as of Scala 2.12.5.

This project also includes some examples of using Mockito to express expectations declaratively. For example, we can test whether the Iterator.map method is lazy in terms of invoking next on the original object only when we invoke next on the result of map:

@Test def mapIsLazyUsingSpyFrom(): Unit = {
  val it = spy(Iterator.continually("hello"))
  val result = it.map(_.length)
  verify(it, never).next()
  result.next()
  verify(it, times(1)).next()
}

For a more in-depth discussion on this topic, please refer to this paper (5 pages):

Tests as Maintainable Assets Via Auto-generated Spies:
A case study involving the Scala collections library's Iterator trait
Konstantin Läufer, John O'Sullivan, and George K. Thiruvathukal
In Proc. 10th ACM SIGPLAN Scala Symposium, July 2019, London, UK. https://arxiv.org/abs/1808.09630

Also, make sure to use reference types as to instantiate any SUTs based on generic Scala traits; see also

mockito/mockito#1605

About

Example for ACM 2019 Scala Symposium paper Tests as Maintainable Assets Via Auto-generated Spies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages