Move this logic into the TestCase subclass that uses it.