Saturday, April 25, 2015

4/25/15 - More Unit Tests

Today, I let Finn drive and he started writing the BookDownloadManager tests, although we didn't get to a point where the tests actually do anything.

I also noticed that somewhere along the way I had broken the BookDownloadManager in our app, even though it passed all the tests. This was because I had forgotten to pass an HttpRequestHandler into the object in app.js on this line that I was passing in correctly in the tests. Mr. Elkner suggested standardizing the way the objects are generated between the app and the tests. Another solution to this problem would be to throw an exception if something vital is missing from the arguments object. Unfortunately, neither var b = vital_arg || throw Error or var b = vital_arg ? vital_arg : throw Error work, so we would need an if statement for each variable we want to ensure is defined.

I emailed Kevin and linked him to yesterday's blog post, where I had complained about how long this it statement was. He said that I was right in being suspicious about the length, and that the test is testing more than one thing. He suggested splitting this test into two, one to test chapter, and one to test book. In hindsight, this is really obvious and I should have figured it out on my own. Also, it made me realize that the wording on the test is wrong. It says that the BookPlayerPageGenerator actually 'generates download book and download chapter buttons', which isn't true; it only adds onclick events to the existing elements.

No comments:

Post a Comment