[]
Managing Test Data for Functional Tests
[ tirsen ] 03:48, Wednesday, 10 November 2004

I love automatic functional tests. They are the most valuable type of automated tests you can do. They give me confidence to do refactorings without regressions. They give the business confidence to release the software when they feel enough functionality is there. They make it possible to release updates to production systems without having to do a long and expensive manual test cycle.

In short, it allows me to be agile.

So functional tests are the most valuable tests you can have. But they are also the most expensive. They are expensive to write, they are expensive to maintain, they are slow to run. When they fail they are very hard to debug and figure out how to fix them. When you change functionality you need to go through your test suite and determine what tests needs to be changed and what tests needs to be removed. As the system grows this becomes more and more tedious and hard work.

Something I'm struggling very hard with now is how to manage test data for functional tests. In order to write a simple test for, for example, a paging list I need to set up all these different objects in the domain to the right state. When some constraints or rules are changed in the domain I need to go through all this test data setup code to make everything obey the new situation.

As the system grows the problem becomes bigger and bigger. It is very hard to get reuse of the test data setup between tests as each test has special needs on the data it uses. I can't use something like mock objects to just mock out where the data is read in because this is a functional tests and I want to test as much as possible with each test. The more I test, the more valuable the test is.

I can use something like the Object Mother pattern but it only provides for individual objects. I need something higher level than this, something that can set up scenarios of objects that can be reused between tests and still allow the tests to tune these scenarios to fit their special needs.

I just don't know how to solve this, it seems to be a significant non-trivial problem of very large functional test suites.

What have other people done out there? What has worked (that I can try) and what has not worked (that I don't have to try)? I could use some help!


Comments

I have stored my domain model in a xml file (e.g. with XStream). So I have a xml file for every test that uses different data. In the setup method from a test I import the xml file. One big disadvantage is when you refactor your domain model you have to refactor it also in the xml files, or you create new ones.

--Reto Breitenmoser, November 10, 2004 08:24 AM

I use http://www.dbunit.org/ for unit testing but also to setup the database with data before launching JMeter functionnal tests to be sure my webapp always begins with the same data each times.
Integrated with ant you can inject xml dataset (and create then dynamicaly) into db before the tests (http://www.dbunit.org/anttask.html)

--Benjamin Francisoud, November 10, 2004 08:54 AM

I have published one possible solution about this here: http://themindstorms.blogspot.com/2004/10/independent-ioc-ish-unit-testing.html

Maybe it can help you. If it does, pls drop me a line.

--the_mindstorm, November 14, 2004 03:14 PM
Post a comment









Remember personal info?