Loading...
Flash Player 9 (or above) is needed to view slideshows. We have detected that you do not have it on your computer.To install it, go here
 
Post to Twitter Post to Twitter
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons
SlideShare is now available on LinkedIn. Add it to your LinkedIn profile.

Introduction to Rails' Unit Testing

From mjuneja, 2 years ago Add as contact

1344 views | 0 comments | 0 favorites | 0 downloads | 0 embeds (Stats)

Categories

Groups/Events

Embed in your blog options close
Embed (wordpress.com) Exclude related slideshows Embed in your blog

More Info

This slideshow is Public
Total Views: 1344 on Slideshare: 1344 from embeds: 0
Flagged as inappropriate Flag as inappropriate

Flag as inappropriate

Select your reason for flagging this slideshow as inappropriate.

If needed, use the feedback form to let us know more details.

Slideshow Transcript

  1. Slide 1: Hello(Mic).Testing (1,2,3) { :by => { :name =>“Manik Juneja”, :company => “vinsol” } } www.vinsol.com
  2. Slide 2: Warning • This presentation is not about standards. • So let’s restore the sanity and look at some code here. www.vinsol.com
  3. Slide 3: Testing Testing, one of the most important, yet most looked down upon component of software development Most of us as developers, do certain amount of testing. The question is how much of that is automated. So that when we make a change here we are sure that we did not break something there. www.vinsol.com
  4. Slide 4: Testing and Rails The Rails framework has inbuilt support for three levels of testing 3. Unit Testing of Models 4. Functional Testing of Controllers 5. Integration Testing of Applications www.vinsol.com
  5. Slide 5: Fixtures • Fixtures allow us to specify a set of known data to be available in the table, at the start of every unit test. • Fixtures are transactional • Fixtures are instantiated, allowing us to access them within the test cases. www.vinsol.com
  6. Slide 6: assertions These are the most frequently used assertions. • assert(boolean, message) • assert_equal(expected, actual, message) • assert_not_equal(expected, actual, message) • assert_nil(object, message) • assert_not_nil(object, message) There are a lot more, and it is easy to write your own customer assertions too. www.vinsol.com
  7. Slide 7: rake To run all unit test cases for an application $ rake test:units www.vinsol.com
  8. Slide 8: When to write unit tests. From Agile Developer Venkat’s blog post titled “Walking along the development beach” http://www.agiledeveloper.com …....Think of your code as your left foot. Think of your unit test as your right foot. It really does not matter which foot you put forward first. However, when taking a nice walk on the beach, you wouldn’t let one foot take a mile walk before dragging the other foot to catch up. To keep your balance and make the walk pleasant, you follow a rhythm, placing one foot forward and following it with the other foot within safe and comfortable distance. ….. www.vinsol.com