I've recently completed a version 1 implementation that allows folders of HTML files to appear as read-only pages in the FitNesse wiki. These pages can be executed as tests, navigated and searched as if they were actual wiki pages. This is a brief technical description of this implementation.
FitNesse already contains a class hierarchy of wiki page types, rooted at WikiPage. FileSystemPage is the concrete class that represents a normal wiki page. I added two new classes, ExternalSuitePage and ExternalTestPage, to represent a folder of HTML files and an individual HTML file.
FileSystemPage had an existing method, createChildPage, that created FileSystemPage objects for each of its sub-folders. I modified this method to use the following rules:
- a folder with a context.txt file is a FileSystemPage
- a folder with any *.html files is an ExternalSuitePage
Within the scope of my changes, I made a couple of refactorings. I created a PageRepository class to encapsulate the knowledge of how pages are stored in the file system. I also created a FileSystem interface with production (disk-based) and test (memory-based) implementations so I could write tests that created various file system states without hitting the real file system.
This first version of the feature works well: I've used it on my fitSharp test suite of over a hundred HTML files. But there are a few caveats:
- If you use the ?edit or ?properties URL syntax, you can get to the edit and properties pages, but they will fail if you try to save.
- The contents of the HTML files are placed as is inside a FitNesse page, and may break the page display if there are unbalanced tags or other HTML problems that may not be apparent when the HTML is displayed on its own.
- Hyperlinks, images, Javascript files and other external references in the HTML may not behave as expected when placed inside a FitNesse page.
- Wiki page names are generated from the HTML file names, but there is no check to avoid potential name collisions. For example, TestA.html and testa.html will both generate TestA as a wiki page name.
No comments:
Post a Comment