public interface CsvTestDataBuilder<T> extends StringBasedBuilder<CsvTestDataBuilder<T>>
This interface specifies a test data loader which loads data from CSV files. CSV files are describing a tabular structure, therefore the loaded result is a list of java objects.
With the withId(String) method we can specify an optional identifier for the loaded CSV file.
The load() method returns the loaded java list.
The loadString() method returns the CSV content of the test data.
The StreamBasedBuilder.openStream() method opens a stream which contains this content.
By default, the file is loaded with UTF-8 character set. We can change this with the StringBasedBuilder.withCharset(java.nio.charset.Charset)
method.
TestDataBuilder.fromCsv(Class)| Modifier and Type | Method and Description |
|---|---|
List<T> |
load()
Loads the test data from CSV file, and convert it to a list of java objects.
|
String |
loadString()
Loads the test data from CSV file.
|
CsvTestDataBuilder<T> |
withId(String testDataId)
With this method we can specify an optional identifier for the loaded CSV file.
|
withCharsetopenStreamCsvTestDataBuilder<T> withId(String testDataId)
testDataId - an identifier of the loaded CSV fileList<T> load()
null.String loadString()
null.
If the test data is coming from multiple files then the header of these files should be the same, otherwise a runtime exception will be thrown.loadString in interface StringBasedBuilder<CsvTestDataBuilder<T>>StringCreated by Kornél Simon, 2022