Section 28.9. Ordered-List Tables


28.9. Ordered-List Tables

We now look at the use of ArrayFixture, as introduced in Section 10.6 on p. 78. The fourth table of Figure 28.6 starts with the action ordered list. This leads to a call of the method orderedList() in the flow fixture object of class Discounts, as shown in Listing 28.8.

This method returns an ArrayFixture that is created with the actual collection. The ArrayFixture checks this collection against the expected collection from the rest of the rows of the table. Figure 28.7 shows some of the interactions of tables and fixtures when Fit runs this table.

Figure 28.7. Fit Runs the Fourth Table of Figure 28.6


As well as taking account of the order of the elements of a collection, ArrayFixture and RowFixture have several differences.

  • ArrayFixture accepts any Java Collection or an Iterator, as well as an array (Object[]). Any of these can be supplied through the constructor, so a subclass is not needed.

    To allow for collections whose elements are not object based, such as the collection shown by a JTable, ArrayFixture accepts a collection of Map. Each Map provides a mapping from a name to an object. Chapter 32 shows how this can be used in testing a GUI.

  • With ArrayFixture, you don't specify the class of the elements of the collection.

  • ArrayFixture maps header labels to properties, as well as to public instance variables. For example, the label name would be mapped to the getter method getName().

  • ArrayFixture allows for mixed collections of objects. When a specific column doesn't apply to a particular object in the collection because it has no corresponding instance variable or property, the associated cell has to be empty.

    If a column applies to no elements of the collection, an error is given, as it's likely that a mistake has been made in the header label.

These differences also apply to SetFixture and SubsetFixture, which are closely related to ArrayFixture.



    Fit for Developing Software. Framework for Integrated Tests
    Fit for Developing Software: Framework for Integrated Tests
    ISBN: 0321269349
    EAN: 2147483647
    Year: 2005
    Pages: 331

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net