10-24-2011, 08:23 PM,
(This post was last modified: 10-24-2011, 08:36 PM by RobertShiplett.)
|
|||||
|
|||||
TDD with Curl (part 1)
The Curl External_Library project has a link at curlap.com for an automated GUI testing framework. A demo can be run by loading
http://developers.curlap.com/curl/curl-e...tests.curl The challenge to doing Test-Driven Development in the classic Curl IDE is that TDD in Kent Beck's view is based on refactoring. Kent began in Smalltalk which was the programming IDE that gave us the first refactoring class browser and then SUnit, the first graphical unit testing framework (my first contract in Smalltalk was to work on a testing scenario and script manager on an IBM banking project back in 1991 when we had neither.) XUnit is now a standard module for many programming environments across languages, but Class Browsers intended for refactoring continue to evolve in Smalltalk (see squeak.org and pharo-project.org for examples.) The first step in TDD is to write a test that fails. That presupposes an XUnit testing framework. The second step is iterative small-step refactoring to run a test Green, add a functional increment, run test RED, add something redundant, run test Green, refactor to incrementally remove redundancy. Many small steps. Many test runs. Tolerate what is needed to get a test to run. When all functionality is present, all redundancy is refactored, all tests are Green: we are done (as far as our unit-testing this piece of a project is concerned - other testing layers supervene, issues arise, requirements change, user acceptance may vary, whatever -we reiterate.) But how to write that first failing test in Curl using CurlUnit? In Eclipse Helios with the 7.0.5 Curl CDE, here is my test-runner: {curl 7.0 applet} {curl-file-attributes character-encoding = "windows-latin-1"} {applet manifest = "manifest.mcurl", {compiler-directives careful? = true}} {import * from COM.CURL.CDU.CURL-UNIT} {import * from COM.CURL.CDU.CURL-UNIT-UI} {install-style-sheet null, look-and-feel = the-standard-look-and-feel} || insert first GeoFrame code here ? {include "test-cases/test-geoframe.scurl"} || test-suite {let public test-UI:Graphic = {test-ui test-suite, target = TestTarget.current}} {set test-UI.width = 20cm} {set test-UI.height = 16cm} {{Dialog test-UI}.show-at-xy title = {host-localize "TestGeoFrame"}, 1mm, 1mm} |# ||--ALT-SH-X then c to run-as Curl Applet ||--notes CTRL-/ for COMMENT toggle ||--this is CDE 7.005 under Helios release 2, i.e., not Indigo ||--select item then CTRL-SH-F3 to see type of selected item; SH-F2 for Curl Documentation Viewer #| At the far end of the test spectrum is CurlUnit's AppletTestCase to test an applet load, but we have not yet written that first failing test for GeoFrame. We might be getting ahead of ourselves to start with a TestClassSuite for our new class. What is required is a kind of GeoFrame such as we see at the end of the en.wikipedia.org article on Dawson Creek as the last item of its External Links section. Those last links are embedded in a widget. The widget is built usng wiki markup which you can see by clicking 'edit' for that section. I have posted that markup and an image of the widget at eclectic- pencil. Our task is to use TDD to develop the same kind of open-source widget for a Curl web page. When such a GeoFrame finally instantiates with component links, we can test with COM.CURL.EXT.AUTO-TEST from the new open-source Curl External Library using its GuiGesture by processing log records. The Curl Eclipse plugin catches so many errors that we have to be attentive to how we can write Red, i.e., failing tests before coding to run Green tests. A good idea of how to proceed can be found in the source code ./tests folders of the External Library project. For example, t-worksheet.curl has Code: let suite:TestSuite = We could begin with a test-suite with the simplest use of the macro {test-case } for a SimpleTestCase: Code: {test-case "empty", But it would not fail. [to be continued in Part 2]
Robert Shiplett, Curlr
Fredericton NB Canada |
|||||
« Next Oldest | Next Newest »
|
Users browsing this thread:
1 Guest(s)
1 Guest(s)