Wednesday, March 16, 2011

Automatically generating test cases

I'm writing a script a script to test a third party XML interface, using the python unittest module.

First of all, is this a reasonable use of unittest, using an API we wrote, but actually testing the interface it's connecting to?

Secondly, I have a huge list of fields I want to test. The code to test each field is identical. I want to test each field as a separate test case, so that they all get tested, even if one fails, but I don't want to have to copy and paste the code for each field changing just the field name. What would be the best way of doing this using unittest?

From stackoverflow
  • In general, test generators brake the rule of unit tests.

    I would not test every bit of code, because the profit is less compared to the effort to build these silly tests.

    So try to write a test generator, but's not as meant by the inventor.

    SpoonMeiser : The interface we're testing is third party, and buggy. We want to be able to report on what works, and what remains to be fixed when they update it, hence wanting to test every field.
    SpoonMeiser : Also, I've re-read that sentence several times now, and I still don't understand it.
    Adam Jaskiewicz : You're not the only one.

0 comments:

Post a Comment