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: GedB::Rushcoding::co::uk at: 10-May-2007 15:37

On 5/8/07, melatiah-gmx.net <melatiah-gmx.net> wrote:
> Hi All, > > I'm a newbie to REBOL and TDD/run.r > > I like the the concept of TDD. I have read through the case study by the author of run.r ( a great program) > > I can see how the test framework operates on the maths functions presented. But how would it be applied to functions that operate on strings or perhaps to display a button object? > > Perhaps its my understanding of TDD at fault, but TDD encourages testing everything to get good coverage, well ideally 100%. >
Melatiah, One of the great benefits of TDD is that it encourages separating out your code into reusable, testable modules. This first problem is telling you something very clear: you're design is too tightly bound to your user interface. If you can't test your code without using the GUI, then you can't use the code without using the GUI. What if, later on, you want to add a web or command line interface? When writing real applications you'll never want to write something that just pushes a button. Pushing a button is just the users way of indicating an action. When the user clicks on the button, what is supposed to happen? For example, perhap a user pushes the button to add another item to an order. In which case you actually want to test AddItemToOrder. After the call, ensure that the order has one more item, and that the new item is the on you added. What you are doing is starting with the Test inteface rather than the Graphical User Interface. The Test Interace is extremely simple, making it easy to write and easy to automate. It also provides a cheap interface that you are more willing to throw away if you find your initial designs are off. When you have built up a healthy test interface, then you can add a View, HTML, Ajax, Command Line or whatever. For an example of where this approach can read, take a look at Ruby on Rails ( www.rubyonrails.org ) or Naked Objects ( www.nakedobjects.org ) These frameworks allow the GUI to be automatically generated from the domain object model. Ged.