Fit for Developing Software: Framework for Integrated Tests
33.6. Transaction Fixture
"Now we need a fixture that connects to the ClientTransaction in RentEz and carries out actions on it," Emily suggested.[1] [1] See Section 28.5 on p. 234 for an introduction to this approach. "Yes," replied Neo, "we can pass the ClientTransaction object to it when we create the DoFixture." Emily added support for transactions through a separate DoFixture object. The method beginTransactionForClientStaff() in class StartApplication, as shown in Listing 33.4, corresponds to the first action in the Fit table in Figure 33.3. Listing 33.4. StartApplication.java (part 3)
public class StartApplication extends DoFixture { private RentEz rentEz; public Fixture beginTransactionForClientStaff(String clientName, String staffMemberName) throws MissingException { ClientTransaction transaction = rentEz.beginClientTransaction( clientName,staffMemberName); return new TransActionFixture(rentEz,transaction); } } This method returns a new transActionFixture, which defines methods corresponding to the actions used in a transaction table. For example, four of the methods of class transActionFixture are shown in Listing 33.5. Figure 33.4 shows the interaction of the tables, fixtures, and application objects for tests involving a business transaction. Note how the TRansActionFixture object acts directly on the ClientTransaction object within the system under test. Figure 33.4. Managing a Business Transaction
Questions & Answers
As the separation of the domain objects and the UI is carried out, one roadblock to testing has been removed. The next hurdle is domain objects that have database managementor other forms of persistencetangled within them. |