I'm writing some unit tests for one of my rails models. It's a large model and in some cases I have dozens of assertions for many of the methods. I prefer using plain test/unit with rails' activesupport syntax so I have a file like this:
require 'test_helper'
class ItemTest < ActiveSupport::TestCase
test "for_sale? should be true if cond 1..."
test "for_sale? should be true if cond 2..."
test "for_sale? should be true if cond 3..."
test "for_sale? should be true if cond 4..."
test "for_sale? should be false if cond 1..."
test "for_sale? should be false if cond 2..."
test "for_sale? should be false if cond 3..."
test "for_sale? should be false if cond 4..."
end
and so on for each of the methods. The problem is the test are becoming increasingly complicated because I can no longer rely on setup() because the context for each group of tests is so vastly different for each method. Also, it's difficult just to test the method I'm working on without running all the tests.
How do others manage large test cases like this? Is there a best practice?