|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Inherited public @interface DataSet
Annotation indicating that a data set should be loaded before the test run.
If a class is annotated, a test data set will be loaded before 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, first a data set named 'classname'.'testmethod'.xml will be tried, if no such file exists, 'classname'.xml will be tried. If that file also doesn't exist, 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 DataSet in which case you specify the dataset that needs to be loaded before this test method is run. Again, a file name can explicitly be specified or if not specified, the default will be used: first 'classname'.'methodname'.xml and if that file does not exist 'classname'.xml. Examples:
' @DataSet
public class MyTestClass extends UnitilsJUnit3 {
'
public void testMethod1(){
}
'
' @DataSet("aCustomFileName.xml")
public void testMethod2(){
}
}
Will load a data set file named MyTestClass.xml or MyTestClass-testMethod1.xml for testMethod1 in the same directory
as the class. And for testMethod2 a data set file named aCustomFileName.xml in the same directory as the class is
loaded.
public class MyTestClass extends UnitilsJUnit3 {
'
public void testMethod1(){
}
'
' @DataSet
public void testMethod2(){
}
}
Will not load any dataset for testMethod1 (there is no class level data set). Will load a data set file named
MyTestClass.xml or MyTestClass.testMethod2.xml for testMethod2.
Optional Element Summary | |
---|---|
Class<? extends DataSetFactory> |
factory
The factory that needs to be used to read the dataset file and create a MultiSchemaDataSet
object |
Class<? extends DataSetLoadStrategy> |
loadStrategy
The strategy that needs to be used to get the dbunit dataset into the database |
String[] |
value
The file name of the data set. |
public abstract String[] value
public abstract Class<? extends DataSetLoadStrategy> loadStrategy
DataSetLoadStrategy
. Use the default value DataSetLoadStrategy
to make use of the default loadStragegy configured in the unitils configuration.public abstract Class<? extends DataSetFactory> factory
MultiSchemaDataSet
object
DataSetFactory
. Use the default value DataSetFactory
to make use of the default DataSetLoadStrategy configured in the unitils configuration.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |