fit is WardCunningham's Framework for Interactive Tests. It reads user test specifications (input data, expected results) in HTML tables; executes some user test code; and colour-codes the HTML output accordingly. Zwiki can apply fit to tables within a page. Here's how it looks. The last column's cells should be green and red.
- fit's home site
- more about python fit
- UnixReview?: Regular Expressions, Fit makes for good tests
- fit reads HTML tables which are simple test specifications. Each table names a fixture class in it's first cell, and contains method names, attribute names, and test data in the others
- The fixture class is based on one of fit's base Fixture classes, with your own test code added. Eg ColumnFixture, RowFixture, ActionFixture; each interprets the table data in a particular way.
- The class is instantiated; methods and attributes are called, set and checked according to the Fixture class's semantics
- cells are coloured and marked up depending on the results. Scroll down to see more examples.
A wiki is a convenient place to browse, develop, and run fit tests.
Zwiki has support for fit built in and enabled by default.
On each page view, any HTML, StructuredText or RestructuredText tables
containing fit tests are parsed, run and coloured. Note, the CVS python fit
version used here processes only tables which contain
fixtures. in their first cell, to co-exist with non-fit tables and help
with security. The fixture class is assumed to be somewhere in Zope's
PYTHONPATH or in the ZWiki product directory. There may be security &
performance issues for public sites.
Most pages on this wiki use StructuredText formatting. You need to be clever to avoid structured text or wiki formatting interfering with your tests. Eg put a ! before a wiki-named class name in the first cell. StructuredTextTables may work, but STX tends to mess up numbers by turning them into bullets.
Here's the best way to get fit working with Zwiki:
- you might need python 2.3
- preferably, run the latest zwiki ; it reports problems better
- check out the
latest python fit into your
ZWiki plugins directory (
darcs get http://zwiki.org/repos/fit)
- restart zope
- copy this page's text to a StructuredText page on your wiki and see if the tables are coloured.
On my system I have a stx page contain the words " ... as you set fit." which triggers the error:
Traceback (most recent call last): File "/var/zope/Products/ZWiki/plugins/Fit.py", line 29, in ? from fit.Parse import Parse ImportError: No module named fit.Parse
if page.hasFitTests(): t = page.runFitTestsIn(t)
And plugins/Fit.py says:
def hasFitTests(self): """ Does this page have any tables containing fit tests ? Should match python fit's regexp. """ return re.search(r'([Ff]ixtures|\bfit)\.',self.read() ) is not None
All this looks kind of cludgey to me and probably doesn't work this way any more... One more reason to upgrade?