Slideshare.net (beta)

 

All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 0 (more)

Introduction to Rails' Unit Testing

From mjuneja, 1 year ago

1246 views  |  0 comments  |  0 favorites
Download not available ?
 
 
 

Groups / Events

 

 
Embed
options

More Info

This slideshow is Public
Total Views: 1246
on Slideshare: 1246
from embeds: 0

Slideshow transcript

Slide 1: Hello(Mic).Testing (1,2,3) { :by => { :name =>“Manik Juneja”, :company => “vinsol” } } www.vinsol.com

Slide 2: Warning • This presentation is not about standards. • So let’s restore the sanity and look at some code here. www.vinsol.com

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

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

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

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

Slide 7: rake To run all unit test cases for an application $ rake test:units www.vinsol.com

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