ch.inftec.ju.testing.db.DataSetExport Maven / Gradle / Ivy
Show all versions of ju-testing Show documentation
package ch.inftec.ju.testing.db;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation to export (and verify) test data after the test has succeeded. When verifying, the resource
* must be present on the classpath for comparison.
*
* The data is exported as soon as the test succeeds, before any verifiers are run.
*
* By default, the data set is exported to src/main/resources/dataSetExport
to a name
* like TestClassName_testMethodName.xml
. Any leading non-alphabetically characters
* will be stripped, e.g. _01_test -> test
*
* The target location can be modified using the targetDir
attribute.
*
* No export will be performed if the property ju-testing.export.compareToResource
is true.
* In this case, the export will be done in-memory and compared to a resource on the classpath, using
* the resourcePrefix
attribute to resolve it.
* @author Martin
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface DataSetExport {
/**
* Name of the data set that contains the tables we should export.
* @return Path to the export data set XML file resource
*/
String tablesDataSet();
/**
* Target directory to copy resources to.
*
* Defaults to src/main/resources/dataSetExport
* @return Data
*/
String targetDir() default "src/main/resources/dataSetExport";
/**
* Name of the dataset export.
*
* Defaults to empty string which means that the name is automatically computed by the class and
* method name.
* @return export name
*/
String exportName() default "";
/**
* Prefix of the resources on the classpath, used to perform.
*
* Defaults to dataSetExport
* @return resource prefix
*/
String resourcePrefix() default "dataSetExport";
/**
* Flag that indicates if the file should be exported physically. Defaults to true.
*
* If false, the export is printed to the Logger and can be used as XMLDocument in a
* DataVerifier.
*
* If physical export is disabled, there will be done no resource verification either.
* @return Whether export should be physically written to a file
*/
boolean doPhysicalExport() default true;
}