jralls at ceridwen.us
Tue Mar 27 12:22:15 EDT 2012
On Mar 27, 2012, at 1:39 AM, Colin Law wrote:
> On 26 March 2012 23:14, John Ralls <jralls at ceridwen.us> wrote:
>> On Mar 26, 2012, at 1:45 PM, Colin Law wrote:
>>> On 26 March 2012 15:15, John Ralls <jralls at ceridwen.us> wrote:
>>>> Do you know how to write automated tests -- in any language -- that accurately check the output format of an HTML page? Automated in this case means the test program decides whether the formatting is correct, no human involved. If you do, or know where I can learn that, please share.
>>> Ruby on Rails has various tools that allow automated testing of html
>>> output (designed for testing web apps), but I don't know that much
>>> about them or how they could be used with gnucash. It would need a
>>> working Ruby environment I believe with the appropriate Ruby Gems
>>> installed and so may not be appropriate.
>> Got a more complete pointer? A particular Gem, maybe? What I found  don't appear to do post-render checks. Most of the search results focussed on testing the Ruby rather than the HTML. That said, validating the HTML for well-formedness would be a pretty good start. There are C, Perl, and Python tools for doing that. A Ruby tool would be OK, too -- I made the Git tools that we use for synching with the Subversion repository by translating a Ruby Gem and then elaborating it.
>> John Ralls
>>  http://guides.rubyonrails.org/testing.html
>>  http://strugglingwithruby.blogspot.com/2010/04/testing-for-valid-html.html
> Section 4.6 Testing Views in the rails guide, [1 above] gives a brief
> overview of how to check html elements. Also there is rspec that is
> considered by many the best route at the moment (for use with Rails of
> course). See  for a quick rundown.
>  http://www.arailsdemo.com/posts/37
Ah. I learn from that link that Rspec is Ruby's implementation of "Behavior Driven Development" . Since Gnucash is a "legacy"* project, it's a bit late -- or early -- to embrace that paradigm., but we can still apply the testing strategy.
It doesn't appear to me that Rspec would work very well testing non-Ruby programs, but I'm willing to be convinced otherwise. But that might be unnecessary if we can find tools which are a better fit. For example, I quickly found cspec  (unfortunately not seriously maintained) and lettuce  for C and Python, respectively. Nothing directly for Scheme, but  points to some (Emacs) Lisp frameworks which could probably be adapted without too much work. Christian might find "c plus plus Behavior Driven Development tools"  interesting. I don't know that any of these tools have the direct support for html testing the Rspec does (I'd guess that they don't), but HTMLDiff , a Python program, might be helpful either as-is or as a guide for writing something in Scheme.
* By "legacy", I take the meaning from Feathers, "Working Effectively with Legacy Code" : Code developed without unit testing. Gnucash could be considered legacy in some other meanings, too, in that the original developers are no longer involved or that it isn't completely object-oriented (and even the parts that are aren't necessarily well designed). I highly recommend the book, by the way.
More information about the gnucash-user