I'm trying to verify that a logger gets called. The problem is that it returns void and so it's recommended that I use a spy instead of a stub. Unfortunately, the spy is acting funky (not working). Ideally, I would also like to remove the "msg" and use a matcher.
The code is below. I've also tried the approach given by https://stackoverflow.com/a/24150445/555493 and I still get a similar error.
//setup spy
val logger = spy(new Logger)
logger.debug(msg)
//call code
//verify
there was one(logger).debug(msg)
I'm getting this error:
The mock was not called as expected:
Argument(s) are different! Wanted:
logger.debug(
($anonfun$apply$mcV$sp$1) <function0>
);
-> at HttpHealthCheckSpec$$anonfun$35$$anon$11$$anonfun$11.apply$mcV$sp(HttpHealthCheckSpec.scala:176)
Actual invocation has different arguments:
logger.debug(
($anonfun$setupMock$1) <function0>
);
-> at HttpHealthCheckSpec.setupMock(HttpHealthCheckSpec.scala:58)