Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.46 KB

README.md

File metadata and controls

29 lines (22 loc) · 1.46 KB

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