|
Re: First Impression: Scala Goodies
|
Posted: Jan 24, 2012 3:30 PM
|
|
This looks nice. But it brings up some of my doubts about unit tests. As the test is written, you force the implementation because you are testing the wrong "requirement". (If I understand correctly) What if changing the document is very time consuming, say it needs to be stored as some overly-complex XML over a network? One smart implementation might be to check if the new value is the same as the old one, and, if so, do nothing. That implementation possibly fails the "This happens 3 times" part of the unit test.
Testing that a setter got called 3 times is very nearly pointless. Yes, I know, arguably it's officially needed to catch when somebody screws up horribly, but, 99.99% of the time it's just plain pointless. Other than when you first write it, how many times have you seen a unit test that a getter/setter was called fail? IMO, the real requirement isn't that the setter got called 3 times, it's that that the value of the Document is correct[i/], i.e. in this example the value is Array[Byte](0)
|
|