My favorites | Sign in
Project Logo
                
Search
for
Updated Mar 27, 2008 by marcos.silva
Labels: Phase-Deploy
StepByStep  
A tiny step by step guide.

1. Install the plugin

2. Edit your integration test class, adding a static property called "datasets":

class PersonTests extends GroovyTestCase {

        static datasets = ['person']

        void testCountPeople() {
                def c = Person.count()
                assertEquals 5, c
        }
}

3. Create the directory "test/datasets/person". "test/datasets" is the default directory where dbunit-plugin will look for the datasets. The subdirectory person reflects the dataset's name indicated by the "datasets" property.

4. Create a ".xml" file inside person directory (you must write the dataset like a flat xml):

<?xml version="1.0" encoding="UTF-8"?>
<dataset>
        <person id="1" name="Person 1" email="p1@email.com" version="1" />
        <person id="2" name="Person 2" email="p2@email.com" version="1" />
        <person id="3" name="Person 3" email="p3@email.com" version="1" />
        <person id="4" name="Person 4" email="p4@email.com" version="1" />
        <person id="5" name="Person 5" email="p5@email.com" version="1" />
</dataset>

5. Run tests using: grails -Dgrails.env=test test-app-dbunit

For more details about how to use the plugin, see HowToUse page.



Sign in to add a comment
Hosted by Google Code