public class CSVDataLoader extends Object implements Loader
Loader for the CSV based files. This Loader is responsible for reading and writing to a list of CSV
based files and converting them into a data structure which is understandable by the EasyTest framework. It expects
the format of the CSV file to be like this :
testGetItems,LibraryId,itemType,searchText
,4,journal,batman
,2,ebook,spiderman
where testGetItems represents the name of the test method for which the test data is being defined,Loader can also write the data back to the file, either for the given method names or for all
the methods in the file. This is handy when we want to write the output data back to the file.| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
LOG
An instance of logger associated with the test framework.
|
ACTUAL_RESULT, AMPERSAND, COMMA, DOUBLE_QUOTE, DURATION, EMPTY_STRING, EXPECTED_RESULT, SINGLE_QUOTE, TEST_FAILED, TEST_PASSED, TEST_STATUS| Constructor and Description |
|---|
CSVDataLoader()
Construct a new CSVDataLoader
|
CSVDataLoader(List<InputStream> csvInputStreams)
Construct a new CSVDataLoader and also load the data.
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,List<Map<String,Object>>> |
loadData(Resource resource)
Load the data for the given Resource
|
void |
writeData(Resource resource,
Map<String,List<Map<String,Object>>> actualData,
String... methodNames)
Write the data back to the file that is represented by the Resource instance
|
protected static final org.slf4j.Logger LOG
public CSVDataLoader()
public CSVDataLoader(List<InputStream> csvInputStreams) throws IOException
csvInputStreams - the input stream to load the data fromIOException - if an IO Exception occurspublic Map<String,List<Map<String,Object>>> loadData(Resource resource)
public void writeData(Resource resource, Map<String,List<Map<String,Object>>> actualData, String... methodNames)
writeData in interface Loaderresource - the resource instance to which teh data needs to be writtenactualData - the actual data that needs to be writtenmethodNames - OPTIONAL names of methods for which the data needs to be written. If the method
names are not provided, then the data is written for all the test methods ofr which teh data is present
in the actualData parameterCopyright © 2014. All rights reserved.