FitNesse. UserGuide. FitLibraryUserGuide. DoFixture.
FixtureDetails [add child]
FixtureDetails [add child]
Calling a method from an actionThe keywords of an action are concatentated together, with spaces between and converted into a valid Java identifier. This is done using extended camel casing[?].
Rules for coloring
- If an action returns a boolean value, the 'keywords' of that action are colored green if the returns true. If it returns false or throws an exception, it colors it red.
- A 'check special action colors the last cell, containing the expected value, just like ActionFixture''
- A 'reject' or 'not' special action color the action green if the action returns false or throws an exception. Otherwise it colors it red.
- An 'ensure' special action colors the action red if the action returns false or throws an exception. Otherwise it colors it green.
Auto-WrappingThe value returned by the method corresponding to an action may be auto-wrapped with a fixture, as follows:
- A Set object is auto-wrapped with a SetFixture.
- An Object, Collection or Iterator is wrapped with an ArrayFixture.
- An 'Object' is wrapped with a DoFixture. But only if it's not one of the above, nor a Fixture, and doesn't have a static Object parse(String) method.
Fixture as AdapterAn object may be associated with a DoFixture (by calling the method setSystemUnderTest(Object) or through the super() constructor). If there is no method in the DoFixture corresponding to an action, DoFixture tries to call that method on the SystemUnderTest object instead (if it's been defined). (This approach is also used in CalculateFixture[?] and SetUpFixture[?].)
This means that a subclass of DoFixture is only needed as an adapter, when actions don't map directly onto methods of the SystemUnderTest object.
Domain ObjectsIf an action corresponds to a property, the value of that property is returned. The value may be an Object.
Because some Objects are auto-wrapped with DoFixture, it's possible to access and test domain objects directly, without the need to write fixtures.
Tests without FixtureBecause of auto-wrapping and Domain objects, it's possible to use Fit for testing without the need to write any fixtures at all (inspired by Naked Objects).My original aim in introducing these facilities was to enable the use of Fit in teaching beginner programmers, but I found them generally useful.
This approach depends on two experimental special actions in DoFixture:
- A start special action creates an object of the specified class as the SystemUnderTest object. This can be an object of any class that has a public nullary constructor.
- A calculate special action in DoFixture returns a CalculateFixture that refers to the SystemUnderTest object of the DoFixture. This means that the rest of the table is interpreted by that CalculateFixture, without needing a subclass of that fixture.
This may need more work to make it general enough...
Here's a trivial example:
- location gives a copy of the Point of the (x,y) position of the Rectangle:
- The original location is unchanged
- Copyright (c) 2004, 2005 Rick Mugridge, Rimu Research.
- Released under the terms of the GNU General Public License version 2 or later.
Add Child Page to FixtureDetails