org.unitils.dbunit.annotation
Annotation Type ExpectedDataSet


@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
@Inherited
public @interface ExpectedDataSet

Annotation indicating that after having executed a test method, the contents of the unit test database should be equal to the contents of a data set.

If a class is annotated, the content of the unit test database will be compared with a dataset after the execution of each of the test methods in the class. A data set file name can explicitly be specified. If no such file name is specified, the default 'classname'.'testmethod'-result.xml will be tried, if no such file, an exception will be thrown. Filenames that start with '/' are treated absolute. Filenames that do not start with '/', are relative to the current class.

A test method can also be annotated with ExpectedDataSet in which case you specify the dataset that needs to be used for this test method. Again, a file name can explicitly be specified or if not specified, the default will be used: 'classname'.'methodname'-result.xml. Example:

Examples:


 '    @ExpectedDataSet
      public class MyTestClass extends UnitilsJUnit3 {
 '
          public void testMethod1(){
          }
 '
 '        @ExpectedDataSet("aCustomFileName.xml")
          public void testMethod2(){
          }
      }
 
Will check the resulting contents of the unit test database using a data set file named MyTestClass.testMethod1-result.xml in the same directory as the class for testMethod1 and aCustomFileName.xml for testMethod2.


      public class MyTestClass extends UnitilsJUnit3 {
 '
          public void testMethod1(){
          }
 '
 '        @ExpectedDataSet
          public void testMethod2(){
          }
      }
 
Will not perform any dataset check for testMethod1 (there is no class level expected data set). And will use a data set file named MyTestClass.testMethod2-result.xml for testMethod2.

Author:
Filip Neven, Tim Ducheyne

Optional Element Summary
 Class<? extends DataSetFactory> factory
           
 String[] value
          The file name of the data set.
 

value

public abstract String[] value
The file name of the data set. If left empty, the default filename will be used: 'classname'.'methodname'-result.xml. If that file also does not exist, an exception is thrown.

Returns:
the fileName, empty for default
Default:
{}

factory

public abstract Class<? extends DataSetFactory> factory
Default:
org.unitils.dbunit.datasetfactory.DataSetFactory.class


Copyright © 2011. All Rights Reserved.