[vdsm] clean testable code

Giuseppe Vallarelli gvallare at redhat.com
Sun Aug 11 12:57:08 UTC 2013


Talking with my teammates I've noticed that there is some confusion related to what testing means and in general
how tests can improve the quality of the codebase by favouring the development of components that are of higher
quality - unluckily it doesn't favour hair regrowing. Tests are also cool because when done right they represent
an executable form of documentation.

Some intro material:

1 How to Write Clean, Testable Code by Miško Hevery (A Googler)
  http://www.youtube.com/watch?v=XcT4yYu_TTs

2 How to write testable code by Miško Hevery (hands on ;-))
  http://misko.hevery.com/attachments/Guide-Writing%20Testable%20Code.pdf
  Examples are provided in Java but the same principles apply to Python
  as well.

3 TDD by James Shore (a practice created by Kent Beck)
  http://www.jamesshore.com/Agile-Book/test_driven_development.html
  A broad article explaining TDD and related concepts.

4 Difference between state based testing and interaction based testing
  http://martinfowler.com/articles/mocksArentStubs.html

Not so intro - but easier to understand after consuming previous material:

5 Mock Roles, not Objects by Freeman and Pryce
  http://jmock.org/oopsla2004.pdf
  They both wrote a very interesting book: Growing Object Oriented Software: Guided by Tests
  http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627/ref=cm_cr_pr_product_top
  I didn't read it yet.

Points from 3 to 5 mostly describe a different kind of working practice, which is very
opinionated but nevertheless with some interesting ideas. I consider points 1-2 fundamentals.

Enjoy, Giuseppe

I will share new materials if there's some interest on it.


More information about the vdsm-devel mailing list