Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [TDD with run.r] Help needed please...

From: pwawood::gmail::com at: 9-May-2007 20:25

Hi Sash I have been using RUnit and TDD development of Rebol scripts and find it to be a very productive way of working. Most of the xUnit testing frameworks aren't really designed for testing GUI's. The general advice seems to be to separate as much of the program logic as possible from the GUI so that it can be tested. Also most of the test frameworks are designed for testing object methods though of course RUnit can be used to test any named block of code. So building on Anton's suggestion, for testability you could adopt an approach along these lines : my-gui-back-end: make object! [ button-maker: func [caption [string!] [ layout reduce ['button caption] ] ] with a test file along these lines: setup: does [ do %my-gui-back-end.r ;; load the object for testing ] test1: does [ my-button: button-maker "click here" assert object? my-button ] test2: does [ my-button: button-maker "click here" assert-equal button/style 'button ] etc. etc, (Apologies for any errors in the View code, I haven't really used it). As for 100% test coverage of the code, it's good but isn't the guarantee some people seem to indicate. "Data coverage" is equally important. For example, take this trivial function: div: func [a b] [ a / b] Now 100% code coverage is easy: assert-equal div 2 1 2 but there is much more to test: div "1" 2 div 1 0 and so one. So for me a good set of unit tests is a balance between code and data coverage. Regards Peter On Wednesday, May 9, 2007, at 06:23 pm, Anton Rolls wrote: