Excerpt | ||||||
---|---|---|---|---|---|---|
|
...
Definition
Definition |
---|
The SetUpInterpreter is used to simplify the creation of a particular state for the system under development. Once the state is created, we can focus on the business process to test. When a setup table is executed, enter data in the system under development to create the desired state.
|
...
Coloring
will visually show the test result by coloring each testing cell:
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
When the insertion has been executed successfully, add a green cell at the end of the data row with the word entered. |
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
If the insertion has failed because the values specified does not respect a business rule, add a red cell at the end of the row with the word not entered. |
Panel | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
If the insertion has failed because a specified value generates an error, |
...
Writing fixtures for Setup tables
As we've seen in Setup Definition, a table of rules is used to simplify the creation of a particular state for the system under development. Once the state is created, we can focus on the business process to test.
This page shows the fixture code that supports the examples introduced in the Writing a Setup specification.
...
Fixture to create bank customers
Consider the example of setup table described in Writing a Setup specification:
...
The fixture code to support this example in Java is the class AGroupOfCustomersFixture shown below.
...
Show me the code
Code Block | ||||
---|---|---|---|---|
| ||||
public class AGroupOfCustomersFixture { public AccountType type; public String number, firstName, lastName; public Money balance; public static Bank bank; public AGroupOfCustomersFixture() { bank=new Bank(); } @EnterRow public void setupAccount() { if(AccountType.SAVINGS == type) bank.openSavingsAccount(number, new Owner(firstName, lastName)).deposit(balance); else if(AccountType.CHECKING == type) bank.openCheckingAccount(number, new Owner(firstName, lastName)).deposit(balance); } } |
...
How is the table processed?
When it runs this table,
reads the first row to select the interpreter and fixture. It then reads the second row to know what the attribute columns are. Finally, it starts creating entries from the third row down to the end of the table.For the third row
It assigns the data 11111-11111 to number, checking to type, Fred to first name, Flintstone to last name and $250.00 to balance.
It then calls the method enterRow() of the fixture AGroupOfCustomersFixture to open a bank account with the given data.