Oltmans wrote:

    def test_first(self):
        print 'first test'
        process(123)

All test cases use the pattern "Assemble Activate Assert".

You are assembling a 123, and activating process(), but where is your assert? If it is inside process() (if process is a test-side method), then that should be called assert_process().

As you can see, every test method is almost same. Only difference is
that every test method is calling process() with a different value.
Also, I've around 50 test methods coded that way.

We wonder if your pattern is truly exploiting the full power of testing. If you have ~15 different features, you should have ~50 tests (for a spread of low, middle, and high input values, to stress the targeted production code).

But this implies your 15 different features should have as many different interfaces - not the same interface over and over again. That suggests coupled features.

Anyway, the short-term answer is to temporarily abandon "AAA", and roll up your input values into a little table:

   for x in [123, 327, 328, ... ]:
      process(x)

(Also, you don't need the print - tests should run silent and unattended, unless they fail.)

This refactor is the standard answer to the question "I have an unrolled loop". You roll it back up into a table iteration.

However, you lose the test case features, such as restartability and test isolation, that AAA give you.

Long term, you should use a literate test runner, such as (>cough<) my Morelia project:

   http://c2.com/cgi/wiki?MoreliaViridis

Down at the bottom, that shows how to create a table of inputs and outputs, and Morelia does the unrolling for you.

--
  Phlip
  http://zeekland.zeroplayer.com/Uncle_Wiggilys_Travels/1
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to