Yesterday, I was coding a new set of tests for a Picture class. I wanted to introduce an on-disk cache, when the picture is public.

I already had an existing test/unit/picture_test.rb, which I extended.

The tests looked like this:

I knew this was the wrong way to go – the fixture was repeated more than once. Then, I realized that what I wanted was a new TestCase. I had already reached for my mouse to hit New File when I had a flash: what prevents me from simply adding a new class to picture_test.rb ?

I also had another flash: is TestCase the right name ? Shouldn’t it be called TestFixture instead ? Because that is what instances of this class represent – a test fixture.

This is very much akin to Spec::Context, from RSpec.

And you see the tests ? They all respect the one assertion per test. I was quite happy with the results.

Now, I need to refactor those other instances in my test suite…

Leave a Reply

 

Search

A picture of me

I am François Beausoleil, a Ruby on Rails coder. During the day, I work on XLsuite. At night, I am interested many things. Read my biography

Tags

(4) (1) (1) (1) (1) (2) (1) (1) (1) (2) (2) (1) (2) (1) (3) (1) (2) (1) (1) (1) (1) (2) (14) (1) (1) (1) (1) (2) (1) (1) (2) (0) (1) (4) (1) (3) (1) (1) (1) (1) (1) (1) (0) (3) (2) (1) (2) (1) (3) (1) (5) (2) (10) (10) (11) (14) (2) (1) (3) (1) (1) (1) (1) (1) (0) (1) (2) (2) (2) (1) (1) (1) (4) (1) (3) (1) (4) (2) (2) (25) (2) (1) (1) (0) (1) (1) (1) (23) (25) (1) (1) (13) (1) (1) (1) (4) (5) (1) (1) (1) (4) (1) (2) (3) (4) (4) (1) (1) (1) (8) (3) (1) (5) (5) (2) (2) (2) (4) (8) (7) (1) (1) (1) (1) (2) (4) (1) (4) (12) (2) (1) (2) (4) (1) (1) (1) (2) (8) (2) (3) (2) (2) (1) (3) (1) (1)

Links

Projects I work on

Categories

Archives