Skip to content

Commit

Permalink
added test for #114
Browse files Browse the repository at this point in the history
  • Loading branch information
barkhorn committed Jan 7, 2017
1 parent 4fc5a51 commit 12a753f
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -451,6 +451,23 @@ class MockTest extends FreeSpec with MockFactory with Matchers {
}

val m = mock[FinalMethodTrait] //test will not compile if the test fails (cannot override final member)
m.somePublicMethod _ expects * anyNumberOfTimes()
// next line will cause a runtime error and is not valid
// m.someFinalMethod _ expects * anyNumberOfTimes()
}

"mock a trait which has a protected method" in withExpectations {
trait FooTrait {
def somePublicMethod(param: String)
protected[mock] def protectedMethod() = ()

This comment has been minimized.

Copy link
@apiwoni

apiwoni Jul 18, 2019

If you remove actual implementation then this is not going to work.
That is protected[mock] def protectedMethod() without = ()

private[mock] def privateMethod() = ()
}

val m = mock[FooTrait]
m.somePublicMethod _ expects * anyNumberOfTimes()
// next lines will cause a runtime error and are not valid
// m.privateMethod _ expects() anyNumberOfTimes()
// m.protectedMethod _ expects() anyNumberOfTimes()
}
}
}

0 comments on commit 12a753f

Please sign in to comment.