AcceptanceTestsWithFitNesse.
NewRequirements
< Testing with FitNesse | GUI Test >

This is only the HTML version of the original WiKi-based tutorial.
You should download it from here to experience the real thing.


Thought we were finished? The second you think this, the customer will have new requirements.
It's the same thing as with washing your car: it will rain within minutes after you're done with it.
Or if you are in the mood for a phone call, just take a shower. It will ring as soon as you're completely wet.


Special treatment for working time longer than 10 hours

The company found out that 90% of all accidents are caused by tired workers working overtime. So the employer and the workers' council set up a new rule: More than 10 hours of work is not allowed. If the system calculates a working time longer than 10 hours, the overtime will be cut off. As a result people are not very eager to work longer than 10 hours. (Sounds weird to you? Well, come over to good old Germany...er, I already told you that)

Now let's implement these requirements test-first with FIT. At first we have to adapt our test data. This means we have to correct all working time values greater 10 down to 10. Do this now and run the Test again...

...ooh, it's all red! (anybody remember the comercial with the Blendax Anti-Plaque dye test?)

Makes sense, we have to change the code to meet the new requirements. We have to change the class
Here we have to adapt the method getWorkingTimeForDay() appropriately. E.g. like this:

    public double getWorkingTimeForDay(int day) {
double time = getRecordedTimeForDay(day);
double mandatoryBreak = getMandatoryBreak(time);
double dailyBreak = getRecordedBreakForDay(day);
if (dailyBreak < mandatoryBreak) {
time -= (mandatoryBreak - dailyBreak);
}
        if (time > getMaxWorkingTimePerDay()) {
return getMaxWorkingTimePerDay();
}
        return round(time);
}

    public double getMaxWorkingTimePerDay() {
return 10;
}

Done. Now we re-run our Test again...

...aah, nicely green again.

< Testing with FitNesse | GUI Test >


[.FrontPage] [.RecentChanges]