@Target(value={TYPE,METHOD}) @Retention(value=RUNTIME) @Documented public @interface Setup
Annotate test method with @Setup to setup database before the test method executes. Annotate the whole test class to have all its test methods set up database. For example:
@Test @Setup public void myTestMethod { }
By default, system locates sequentially the following files in the package of the class, the first file found wins:
Specify the names of files explicitly in the annotation to override the default file name convention. Multiple files may be specified, system uses all of them. The files are located in the package of the class. For example:
@Test @Setup({ "custom-setup-1.xml", "custom-setup-2.xml", "custom-setup-3.xml" }) public void myTestMethod { }
The setup files must conform to the DBunit's "flat XML dataset" format, which means there is a root <dataset /> element, which contains one element for each row, where the name of the row element specifies the database table and its elements specify the table columns. So, for example:
<dataset> <person name="Joe" /> </dataset>
System performs "clean insert" database operation with all datasets located, which means all tables in the datasets are deleted in reverse order, then all rows are inserted in the order specified.
Use @Setup.List
to define multiple @Setup
annotations on
the same element.
See http://lightair.sourceforge.net/features/setup.html for more info.
Setup.List
public abstract String[] value
public abstract String profile
A profile lets you connect to a different database. A profile must be defined in LightAir properties file and must have its own properties file which defines the connection to the profile database.
Copyright © 2011–2020 Lastware, sro.. All rights reserved.