Class AbstractCsvDataProvider


  • public abstract class AbstractCsvDataProvider
    extends Object
    Generic CSV data provider; you should specialize it for your type by overriding type(), like this:
     public static final class FooCsvDataProvider
         extends AbstractCsvDataProvider {
         @Override
         protected Class type() {
             return Foo.class;
         }
     }
     
    then you can use it like this:
     @Test(dataProviderClass = FooCsvDataProvider.class, dataProvider = AbstractCsvDataProvider.DATA)
     public void shouldReadFromCsv(final Foo value) {...}
     
    Only a single object parameter is supported. If your test method requires multiple parameters, then consider grouping them in a class instead.
    Author:
    aherscu
    • Constructor Detail

      • AbstractCsvDataProvider

        public AbstractCsvDataProvider()
    • Method Detail

      • data

        @DataProvider(name="data")
        public Object[] data​(Method method)
      • csvBuilderFor

        protected com.opencsv.bean.CsvToBeanBuilder<Object> csvBuilderFor​(Reader csvReader)
        Parameters:
        csvReader - the reader for associated CSV file
        Returns:
        iterator over deserialized CSV data
      • type

        protected abstract Class<?> type()
        Returns:
        the type of data that should be deserialized