Testing Business Rules
FitNesse is open source and freely available for
download. You can get the instructions for
downloading and installing the FitNesse server on your own machine. To begin working with Fit take a look at a test table example (see Table 1).
Table 1. Test Table: Put business rules for a car rental business to the test.
com.devx.fit.RentalRates |
age |
car type |
booking method |
rental allowed? |
daily rate? |
25 |
Economy |
Phone |
True |
15.00 |
25 |
Economy |
Internet |
True |
13.50 |
24 |
Economy |
Phone |
True |
16.50 |
40 |
Standard |
Phone |
True |
20.00 |
25 |
Standard |
Internet |
True |
18.00 |
30 |
Exotic |
Phone |
True |
45.00 |
29 |
Exotic |
Phone |
False |
|
17 |
Standard |
Internet |
False |
|
18 |
Standard |
Internet |
True |
20.00 |
|
Table 1 captures several test cases related to a set of business rules that a car rental company might use for determining whether an individual is eligible to rent a vehicle, and if so what the rental rate should be. In this case the business rules are:
- Customers who book their rental online receive a 10 percent discount.
- Customers under 25 years old are subject to a 10 percent fee.
- Exotic cars can be rented only by customers 30 years old or older.
- Customers under 18 years old are not allowed to rent any car.
The table lists several sets of data, as an example, and the expected output for two calculations. This table alone might not communicate completely the business rules the system is required to enforce, but when it is used to augment the English description it does a very good job at removing ambiguity from the requirements. For instance, these test cases clearly show that an exotic car can be rented by a 30-year-old driver, but not by someone who is 29 years old. Based solely on the English description of the rules, this requirement may not have been completely clear. Also, the rate calculation for an underage driver who books his or her rental through the Internet is not immediately clear based on the given rules. Should the online discount be determined based on the original rate or the rate including the 10 percent fee? The test table clearly shows that the former is the correct calculation.