unit testing - How to test an object's private methods in Scala -
i have example object:
object foo { private def sayfoo = "foo!" }
and want test private sayfoo method without following workarounds: 1. without defining package private 2. without defining protected , inheriting in test class
i saw 1 possible solution extend privatemethodtester doesn't seem work objects classes.
now, know some, if not many, not suppose test private methods rather public ones (api). nonetheless, still want test them.
thx in advanced
it cannot tested standard means.
however, if need "cover" section of code, test methods use private method in implementation. indirect, granted, test code.
for example, in class have method:
def dontsaybar = { sayfoo() println("other processing...") }
and "cover" code in private method if tested.
p.s. rule of thumb if see code isn't showing in coverage run, don't need code.
Comments
Post a Comment