mardi 27 octobre 2015

How to test an object's private methods in Scala

I have an example object:

object Foo {
  private def sayFoo = "Foo!"
}

And I want to test the private sayFoo method without the following workarounds: 1. Without defining it as package private 2. without defining it as protected and than inheriting it in the test class

I saw one possible solution which is to extend privateMethodTester but it doesn't seem to work for objects just classes.

Now, I know that some, if not many, say that you are not suppose to test private methods but rather only public ones (api). Nonetheless, I still do want to test them.

thx in advanced

Aucun commentaire:

Enregistrer un commentaire