Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Testing for an Absolute Beginner - I'm using Ruby

I've realised that I really do need to get started on the behaviours and patterns related to unit testing in general and with ruby specifically, as I can then migrate that knowledge to other languages. Are there any really good examples on how to get started? The problem I have is that with the current systems I'm using and working on it seems like getting started with Unit testing is insurmountable.

I've never built a single unit test for operational code other than trying the same fifteen or so online tutorials that show you ruby's core classes seem to function fine. I need to know how to build these tests for my own systems and the mentality of what to look for and test for.

What good tutorials are online that show you how to do more than just test that an assert_true is true and the opposite is false? Even if they're not for ruby, what must-read and must experiment unit testing guide should I read or go over? Preferably one with a step by step tutorial.

Stuff like using these unit tests in actual existing models and frameworks and what to actually test for? I'm still trying to get my head around the testing mentality and I keep getting sidetracked by the different elements. No one's really specifically outlined what mentality you need to approach unit testing with, as all of those who have written guides or tutorials seem to have internalised the logic with which you approach the system.

Any help would be really appreciated.

like image 858
Schroedinger Avatar asked Mar 01 '11 03:03

Schroedinger


1 Answers

Technically it's BDD, but I would recommend The RSpec Book because it does a good job of explaining concepts and has extended tutorials. The second section of the book covers Cucumber, so it will teach you that as well.

like image 196
Stuart Ellis Avatar answered Sep 26 '22 13:09

Stuart Ellis