Weekend Reading: Ruby Best Practice Chapter 1, Driving Code Through Tests
Yes, I'm a little behind with my reading, but it was definitely worth while.
I was happy to find such a good chapter on testing, because most other books only cover trivial testing, but they don't show how to build useful tests.
What did I learn?
* use single tests for every different case. This results in better readability, and in case an assertion fails, I know exactly in which scenario it failed and all assertions in different tests, will be tried, so I'll know right away if all of them failed or just a particular one
* use tests more as a way to drive your software, not only as regression tests
* there's a when? Yes, switch-case is a case-when in Ruby
* goal for next time Ruby programming: force myself to use a stub/mock
* embedding tests in library files
For my math programming (Macaulay2) I rely heavily on tests: for every little function a handful of tests, and a few functional tests, checking the full algorithm. Functional tests are so immensely helpful for math programming, because it's hard to test by hand, if a set of polynomials is exactly the same as expected.
Comments
Post a Comment