Scalamock stub with array parameter

46 views
Skip to first unread message

Mor Sheffer

unread,
Apr 8, 2014, 11:13:35 AM4/8/14
to scalate...@googlegroups.com
Hi,

I have a mock for an object and I'm trying to define a stub for one of its functions, a function that have an array of string in its parameters.
When running the test, I get an exception saying that the array in the stub is different than the actual array.
How can I make them be equal?

The actual call to the function:
    topPredictionsGenerator.generate(numberOfWantedResults, Array[String](currentWords.last), "", Array[String]())

The code in the test:
    val topPredictionsGeneratorMock = mock[ITopPredictionsGenerator]
    (topPredictionsGeneratorMock.generate _).stubs(3, Array[String]("I"), "", Array[String]()).returning(Seq("have", "am", "go"))

Exception:

Unexpected call: generate(3, [Ljava.lang.String;@5781ab44, , [Ljava.lang.String;@2132a3e)

Expected:
{
  generate(3, [Ljava.lang.String;@3abc8928, , [Ljava.lang.String;@2fd0bf38) any number of times (never called)
}

Actual:
  generate(3, [Ljava.lang.String;@5781ab44, , [Ljava.lang.String;@2132a3e)
org.scalatest.exceptions.TestFailedException: Unexpected call: generate(3, [Ljava.lang.String;@5781ab44, , [Ljava.lang.String;@2132a3e)



Thanks!
Reply all
Reply to author
Forward
0 new messages