Dashboard > Struts University > Home > MailReader > MailReader Use Cases > TestData
Added by Ted Husted, last edited by Ted Husted on Dec 07, 2007  (view change)


Arthur is writing unit tests to exercise code for the MailReader object. Some of the tests need pre-existing data, which is dreary to setup by hand. The test data, taken from an early prototype, is

fullName John Q. User
fromAddress John.User@somewhere.com
username user
password pass
host mail.yahoo.com
username jquser
password foo
protocol imap
host mail.hotmail.com
username user1234
password bar
protocol pop3

He talks to Marvin. They decide install Spring Core, and convert the test data to XML Spring beans, so that they can create the test data declaratively, whenever it is needed.


Goal Use Spring to setup background data for testing
Level Subfunction (User Goal, Summary, Subfunction)
Trigger Tests become too complicated to setup data by hand
Primary Actor Developer

Main Success Scenario (MSS)

Step Action
1 Add Spring Capabilities (Core only) to the project
  Add a new spring.xml to the src folder (on the source path).
2 Describe the test data using a set of <bean> descriptors.
3 Instantiate a bean factory in the test's setUp method.
4 Call the factory to create and persist whatever test entities are needed.

Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators