Tag Archives: Testing

Upgrading to Rails 3: @routes is nil

I’m currently in the process of upgrading an application from Rails 2 to Rails 3. Fortunately, it’s not the first time someone does so, and there’s plenty of resources throughout the web that will help you to work it out. In particular, I chose to follow the steps demonstrated by Ryan Bates in an outstanding … more

Posted in Blogs | Tagged , , , |

Parameterized Tests

In order to prevent the dreadful copy-paste habits in unit tests (remember, tests are also code, so all the good practices you use when writing code should also apply to tests) a common pattern to test similar behaviour when slightly changing the input is to extract the test itself into a separate method. The scenario … more

Posted in Blogs | Tagged |

How do I unit-test a class which depends on HttpContext?

Suppose you have to fix a bug in an ASP.NET application. You’re a TDD-guy so once you identify it, you write a test which should reproduce it. Then you run it and… null pointer exception. Your testing framework may have pointed you to the exact line, so you inspect it and see something like: var … more

Posted in Blogs | Tagged , , , |

Tests are also Code

Many times we put all of our effort in developing an elegant solution to a certain problem we have, thus leaving testing to a second place, without too much consideration for it. Regardless of being using TDD or just creating unit tests for the already-written code, keeping tests as clean as the code should also … more

Posted in Blogs | Tagged |

State vs Behaviour Verification

I stumbled upon an excellent article by Martin Fowler in which he describes the difference between stubs and mocks, and afterwards the difference between classic and mockist TDD. Be warned, the article is a few years old, but still a highly recommendable reading. Test Objects In every unit test we usually focus the testing on … more

Posted in Blogs | Tagged |