can you test nested functions in scala?
问题 Is there any way to test a nested function (ideally with ScalaTest)? For example, is there a way to test g() in the below code: def f() = { def g() = "a string!" g() + "– says g" } 回答1: g is not visible outside of f , so I daresay no, at least not without reflection. I think testing g would break the concept of unit testing, anyway, because you should never test implementation details but only public API behaviour. Tracking an error to a mistake in g is part of the debugging process if tests