3 ms·
Writing Automated Tests
- jacquesm 17y agoThat's a really useful presentation. My own experience with testing is this: test code is like the safety net under a trapeze act. It will catch you when you fall, before the consequences are dire (read, your code is in production with a bug). It's not infallible but it will help you a lot if you add some tests to your code. Even if you're not in to perl, if you are not doing automated testing go see this presentation, you won't regret it, it's quick, humorous and makes the point in a friendly way.
- eru 17y agoYes. However why write your own tests? Have the computer generate them for with QuickCheck. (You still have to hand out a way to tell wrong from right.)
- jsankey 17y agoI share the distaste for "holier than thou" proponents of testing. However I have to take issue with the following: Test code is easy to write * It doesn't have to be clean * It doesn't have to be readable * It doesn't have to be robust This is really bad advice. Tests still need to be maintained, so they should be clean and readable like any of your code. Readable tests can also be invaluable for understanding the module they are testing (especially those tricky parts where bugs once lurked). I learned this the hard way myself, and worry that this attitude leads people to wasting a lot of time on test maintenance and eventually giving up on testing.
- jbert 17y agoThe main thrust of the presentation is to lower the bar in people's minds to writing test code. Giving people 'permission' to write sloppy test code makes them more likely to write it. In the context of selling people on writing tests, it is defensible advice. For people who have a lot of tests, then yes, raising the standard for your test code might make sense.
- illumen 17y agoA quick easy way with python is to mess around in the interpreter 'testing'... then paste those tests in as a 'doc test'. That's the quickest way to test that I know of with python... and suits people who code by trying things out in the interpreter. Another quick way is to add asserts in. It's a very easy way to sanity check things, and is usually built into the programming language (it's in C/python etc). cu,