Review of "RSpec vs. Test Unit: How Test Driven Development Works"

When develop a web application, we work in an iterative manner to make code to be deployed as soon as possible. We implement a small feature, test it and make sure it works, and then move on to the next. This is the workflow of test driven development. TDD is a basically repeating write a few line of code and testing.

Manual testing is time consuming, so automated tests are introduced. Besides automated test is really useful in a big team. It help us to prevent to break other feature you don’t know. It is common to have feature you don’t know because the code base is too large for one developer to understand every detail. Automated tests help us to detect error during development. Fixing a bug during development is much easier, because every detail is in our brain. Automated test prevent our feature broken by others, saving us from undoing the feature in the future.

After having automated test, we can improve the code by rewriting it easier. Rewriting a working code is called ‘refactor’. ‘Red/Green/Refactor’ methodology is a workflow that

  1. Write a test first (Red, as the test fail before we implement the feature)
  2. Implement the feature (Green, the test should be passed)
  3. Refactor

Ruby has a unit test standard library, Test::Unit. It is the original test suite. But when developer have to take into account the behaviour that’s expected by users. Test::Unit is not very handy. They invent rspec to replace Test::Unit. They also rename the methodology to behaviour driven development.

RSpec have higher readability(?). Sometimes Test::Unit is easier to write(?). RSpec is more common in industry.

Reference: RSpec vs. Test Unit: How Test Driven Development Works.