@Retention(value=RUNTIME) @Target(value={METHOD,TYPE}) @Inherited public @interface DataLoader
Loader strategy for their test class.
EasyTest supports CSV, EXCEL and XML based data loading. But it may not be sufficient in all the cases.
Also EasyTest's Data Loading Strategy may not suit every user. In such a case, a user can write his own Custom Loader and pass it to the Data Loader annotation
to supply its own custom Loader.
@Test
@DataLoader(loader=MyCustomDataLoader.class)
public void testGetItems(........
@Test
@DataLoader(filePaths={testData.json} , loader=MyCustomDataLoader.class)
public void testGetItems(........
@Test
@DataLoader(filePaths={testData.csv})
public void testGetItems(........
@Test
@DataLoader(filePaths={testDataExcel.xls})
public void testGetItems(........
Loader interface and should have a no arg constructor.
writeData(). Its default value is Boolean.TRUE.
appendData() attribute. If the value is True, then the data from different files is preserved and the test is run
for each row of test data specified in each test data file. if the value is False(also the default value), then the test data in file 1 is overridden with test data in file 2.
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
appendData
OPTIONAL
Boolean identifying whether data specified in two different files for the same method
should be appended or replaced.
|
String[] |
filePaths
OPTIONAL
The list of file paths representing the input test data for the given test method.
|
Class<? extends Loader> |
loader
OPTIONAL
The custom Loader class that will be used by EasyTest to load the test data.
|
LoaderType |
loaderType
OPTIONAL
The type of file that contains the data.
|
boolean |
writeData
OPTIONAL
Boolean identifying whether the data should be written back to the file or not.
|
public abstract String[] filePaths
DataLoader represented by loader() attribute
knows about the test data, this field can be left blank.
public abstract LoaderType loaderType
public abstract Class<? extends Loader> loader
LoaderType is Custom.public abstract boolean writeData
public abstract boolean appendData
Copyright © 2014. All rights reserved.