Section 34.4. Date Formatting


34.4. Date Formatting

When Emily and Neo ran the first test, they expected it to fail with the incorrect date, as they had not yet altered the corresponding code in the application to use the new Clock. But instead, the test failed because of the format of the date values in the Fit table. The standard format for Date was incorrect because it included seconds.

Emily extended the constructor in class StartApplication to call the DoFixture method registerParseDelegate(). This method specifies that Date values from the Fit tables are to be formatted without seconds, using a DateFormat, as shown in Listing 34.7.

Listing 34.7. StartApplication.java (part 2)
 public class StartApplication extends DoFixture {    private final DateFormat dateFormat       = new SimpleDateFormat("yyyy/MM/dd HH:mm");    private RentEz rentEz;    public StartApplication() throws Exception {       // ...       registerParseDelegate(Date.class,dateFormat);    }    // ... } 



    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