lundi 23 novembre 2015

Unit test for Scala object (not class)

I've a singleton class in Scala that's declared as an 'object'. I need to write unit tests that 'mock' methods in this object. How do I do it? I tried using 'PowerMockRunner' etc with no luck.

For example:

object MyClass extends Serializable {
   def apply(): Unit = { ..... }
   def more methods....
}

Now I need to write a unit test that mocks the 'apply' method. How do I do it?

Aucun commentaire:

Enregistrer un commentaire