2015-01-26 1 views
1

ScalaMock 스텁이 인 send(Email) 메서드가 호출되었는지 어떻게 확인할 수 있습니까?MailerAPI.send의 ScalaMocks 스텁이 호출되었는지 확인하는 방법은 무엇입니까?

class SomeTests extends FunSuite with MockFactory { 
    [...] 
    val expEmail = play.api.libs.mailer.Email(
    "Test", 
    "[email protected]", 
    Seq("[email protected]"), 
    bodyHtml = Some(s"""<html> 
     | <body> 
     | Hello 
     | </body> 
     | </html> 
     | """.stripMargin) 
) 
    val mailerFake = stub[MailerAPI] 
    // Won't compile 
    (mailerFake.send _).verify(expEmail) 
    [...] 
} 

위의 코드를 컴파일 할 때, 나는 다음과 같은 오류 얻을 : send 이후

Error:(29, -1) Play 2 Compiler: 
/Users/arve/Projects/gradlehub/test/ui/pub/RegistrationTest.scala:29: ambiguous reference to overloaded definition, 
both method send in trait MailerAPI of type (data: play.libs.mailer.Email)String 
and method send in trait MailerAPI of type (data: play.api.libs.mailer.Email)String 

답변

4

은 컴파일 오류가 이미 말한대로 오버로드를 명시 적 의해 당신이 할 수있는 명확하게 할 수있는 방법을 필요 원하는 유형을 나타내는 send :

(mailerFake.send: (play.api.libs.mailer.Email => String)).verify(expEmail)