Anteater |
October 04, 2002
Posted by ovidiu at 10:27 PM
|
August 06, 2002
In Anteater you define the behavior of a test by specifying various properties which affect the tasks which are part of the test. Up until property groups, you'd have to specify these properties each time you were using a particular task. With groups, you specify these properties in one place, and refer to all of them in your tasks. You can define specialized groups which inherit from a common set of properties, and modify or add new property definitions. Here is Jeff's description of this feature: GroupsGroups are like containers for Anteater objects, allowing reuse of definitions: <group id="mygroup"> <session/> <logger type="xml"/> <property name="host" value="localhost"/> </group> <!-- Each member task inherits the group's logger and session --> <httpRequest group="mygroup" path="/a.html" .. /> <httpRequest group="mygroup" path="/b.html" .. /> Group PropertiesAnteater tasks' behaviour is now configured through properties of the group to which the task belongs. Currently recognised properties are 'host', 'port', 'debug', 'timeout', 'protocol', 'haltonerror' and 'usetidy'. So if we had: <group id="cocoontests"> <property name="host" value="myhost.com"/> <property name="port" value="8080"/> <property name="debug" value="0"/> </group> <httpRequest group="cocoontests" ... /> <httpRequest group="cocoontests" ... /> Then those tasks would run against myhost.com:8080, with debug level 0, unless overridden by attributes on the httpRequest object. Group properties can also be set from outside a group: <property name="cocoontests.debug" value="2"/> This allows group values to be specified in properties files outside the test script, or from the command-line, eg: anteater -Dcocoontests.host=localhost -Dcocoontests.debug=2 -f tests.xml Group InheritanceSince a Group object is an Anteater object, a Group can belong to another Group, either by nesting: <group id="a"> <property name="host" value="myhost.com"/> <group id="b"/> </group> or by the 'inherits' attribute ('group' also works): <group id="a"> <property name="host" value="myhost.com"/> </group> <group id="b" inherits="a"/> Group elements are inherited in what I hope seems a natural manner. Properties are passed through unless overridden, so 'b' in the above example has host 'myhost.com'. Loggers are passed through, unless any loggers are defined in the child group. Same with sessions. The Default GroupThere is an implicit 'default' group, to which all tasks belong unless otherwise indicated. If the default group were written out, it would look like this: <group id="default"> <session/> <logger type="minimal"/> <property name="host" value="localhost"/> <property name="debug" value="0"/> <property name="port" value="BUILTIN,8080"/> <property name="timeout" value="30s"/> <property name="protocol" value="HTTP/1.0"/> <property name="haltonerror" value="false"/> <property name="usetidy" value="false"/> <!-- Declare all other groups as children of 'default' here --> <group refid=".."/> ... </group> So by default, all tasks get a session, and a logger that prints to stdout, plus a bunch of properties used to configure the default Anteater behaviour. The default group can be overridden by the user, by declaring a group with id 'default'. This way, we can override specific properties for all tasks: <group id='default'> <property name="host" value="myhost.com"/> <property name="port" value="8080"/> </group> All other items are inherited from the 'default' defaults. And of course the 'default' group properties can be overridden at the command-line, eg -Ddefault.host=myotherhost.com. Putting it all togetherThe purpose of grouping has been to make simple things easier, and complicated things possible. Some scenarios, from simple to complex:
So we define a hierarchy of groups at the top of the script, and then use it in the subsequent tests. Posted by ovidiu at 04:21 PM
|
|
Cool stuff
Search
More from me
Picture gallery
![]()
Topics
Anteater (2)
Apple (44) Arduino (6) BeagleBone (1) Cars (5) Cocoon (26) Cool gadgets (14) Emacs (24) Google (15) Hardware (9) Java (31) JavaScript (2) Linux (12) Music (4) Open Source (22) People (2) Photo (23) Politics (1) Random (39) Travel (4) Web services (3) Weblogs (30) Work (1) XSLT (12)
Archives
October 2015
January 2015 January 2014 May 2013 June 2011 December 2010 September 2010 August 2010 June 2010 June 2009 May 2009 April 2009 February 2008 November 2007 July 2007 June 2007 May 2007 April 2007 October 2006 August 2006 June 2006 April 2006 March 2006 February 2006 January 2006 December 2005 November 2005 October 2005 September 2005 July 2005 June 2005 April 2005 March 2005 February 2005 October 2004 September 2004 August 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 December 2003 November 2003 October 2003 September 2003 August 2003 July 2003 June 2003 May 2003 April 2003 March 2003 February 2003 January 2003 December 2002 November 2002 October 2002 September 2002 August 2002 July 2002 June 2002
People
Admin
|