Last active
February 8, 2017 11:45
-
-
Save jruusu/a52af5f9380066ddd583 to your computer and use it in GitHub Desktop.
Play 2.4 Specs2 Mockito mocked method answers with multiple arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Play 2.4 Specs2 Mockito mocked method answers with multiple arguments | |
import org.specs2.matcher.ThrownExpectations | |
import org.specs2.mock.Mockito | |
import play.api.test.{FakeRequest, WithApplication, PlaySpecification} | |
class MySpec extends PlaySpecification { | |
class MySpecScope extends WithApplication with Mockito with ThrownExpectations { | |
val programService = mock[ProgramService] | |
programService.find(any[Seq[String]], any[Option[String]]) answers { (args, mock) => | |
val ids: Seq[String] = args.asInstanceOf[Array[Any]].head.asInstanceOf[Seq[String]] | |
... | |
} | |
} | |
"foo" should { | |
"bar" in new MySpecScope { | |
programService.find(Seq.empty, None) ... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment