CurlUnit is a simple framework to write repeatable tests in the Curl content language as executed by the Surge plug-in. CurlUnit is an instance of the xUnit architecture commonly used as a testing framework within the Extreme Programming methodology (XP) methodology. CurlUnit is a derivative work of JUnit 3.7 porting the xUnit core and most of its tests, the simple samples, the Money examples and the cookbook to Curl. Like JUnit before it CurlUnit is Open Source Software, released under the IBM Public License and hosted on SourceForge .
Try it ! (you must have the Suge plugin from Curl.com installed. See Installation for more details about running CurlUnit direct from the web site.).
Curl, XP & CurlUnit! Curl is a content language for the creation of web applications. It scales gracefully from simple static pages to complex applications all within the same programming model.
Curl is ideal for Extreme Programming. It is a dynamic language with first class procedures, a well defined package structure, the capability to load dynamically from any location on the web and a GUI toolkit supporting a declarative style of UI development not dissimilar to Tkl.
CurlUnit demonstrates several of these features, for example loading an applet with a simple GUI off the web, then having that applet dynamically load and run code from another location. The code loaded refers to other code packages on the web. These are transparently loaded if and only if required.
To learn more about Curl visit Curl.com the corporate home of Curl, curlbreaker.com a journal Curl development, includes a mailing list, and curlexamples.com a site with lots of executable examples complete with source code.
|licence.html||copy of the text of the IBM Public License|
|testrunner.curl||an applet that launches the UI allowing tests to be run|
|source||the curl source code of CurlUnit|
|tests||the CurlUnit tests of CurlUnit itself|
documentation and articles
When installing CurlUnit you have the choice of running it directly from the CurlUnit web site or installing it in your local environment. Running CurlUnit directly from the CurlUnit web site minimizes the hassle. The disadvantage is that in order to exercise your own test code you will need to make the CurlUnit applet a privileged applet. Either way a pre-requisit is that you install the Surge plugin or the SugeLab IDE from Curl.com .
It is possible to run CurlUnit directly from this site without installing anything on your local hard drive. Do this by invoking the TestRunner . If you have the Surge plug-in or IDE installed the SimpleTestRunner should launch otherwise you will be prompted to install the Surge plug-in from Curl.com. Before running any tests present in your environment, as opposed to the ones provided on the CurlUnit site, you will need to make curlunit.sourceforge.net a privilaged location. See the documentation for Surge on how to do this. Now it should be possible to verify the installation as described under Verify Installation .
If you choose to run from the CurlUnit site your test packages should import the CURLUNIT.FRAMEWORK package from this site.
Local InstallationBelow are the installation steps for installing CurlUnit to your local hard drive and running it from there:
- unzip the curlunit.zip file
If you choose to run from your own installation of CurlUnit page your test packages should import the CURLUNIT.FRAMEWORK package from your site.
- Test the installation by loading path to CurlUnit /testrunner.curl and using the TestRunner tool to run the tests that come with this release. All the tests should pass OK with the exception of a couple of tests in ./samples/sampletests.curl which are designed to show the outcome of failure.
- Copy the file .samples/mypackage.curl to your local drive and attempt to execute the test file:////
/mypackage.curl#MYPACKAGE.MyTest. This should also run. If not ensure the curlunit.sourceforge.net is a privilaged location and restart the TestRunner.
To get started with unit testing and CurlUnit read the the CurlUnit Cookbook. This shows how to get started with with CurlUnit. You find additional samples in the /samples/sampletests.curl#CURLUNIT.SAMPLETESTS package:
For a more extensive example see /samples/money/money.curl and /samples/money/tests/money.tests.curl. These implement a multi currency money framework and the test cases for it.
For a more sophisticated introduction to xUnit style testing and XP programming see the Java Report article: Test Infected - Programmers Love Writing Tests . This article demonstrates the development process with xUnit in the context of the money example.
Missing core function:
- Display of stack trace: in Curl 1.6 there is no way to extract a stack trace from a Curl exception. Hence it is not possible to display this information in the TestRunner. The work around , at least for errors is to un-check the Catch errors check box. In this case the debugger will be invoked when an error is encountered.
- Automated test extraction: Curl 1.6 does not support introspection of classes. Hence it is not possible to extract all test methods from a test case in an automated way. The work-around is that programmers must maintain a test-method-names method for each test case.
Enhancements, extensions and niceties
- Full feature UI: A UI with widgets allowing uses to browse the test and result hierarchies. Should support things like re-running individual tests with a provision that the debugger will come up on errors and/or failures.
- Refactor to take best advantage of Curl language features: The current design is a fairly literal port from the Java version, itself a port from the Smalltalk version.
- xUnit extensions (TestDecorator and subclasses): Support for repeated testing and parallel testing.
- xUnit add on's (HTTPUnit and the like): These would provide support for testing things like http invocations, setting and checking cookies and similar things.
Ideas for the future
- Explicit support for UI testing: It is not clear what form this would take. One approach might be to dynamically capture events from a GUI. These could then be filtered, parameterized and augmented with assertions to create a test case. This test case could then be run on demand.
A cookbook for implementing tests with CurlUnit.
Related DocumentationTest Infected - Programmers Love Writing Tests
Java - An article demonstrating the development process with JUnit.
JUnit - A cooks tour
Java - An article exploring the design of JUnit on which CurlUnit is based.
Curl, the Curl logo, Surge, Surge Lab, Gentle Slope, Get Curled!, and Curl Connected are trademarks of the Curl Corporation.