Tabnine Logo
FileParameters
Code IndexAdd Tabnine to your IDE (free)

How to use
FileParameters
in
junitparams

Best Java code snippets using junitparams.FileParameters (Showing top 4 results out of 315)

origin: pl.pragmatists/JUnitParams

private Reader createProperReader() throws IOException {
  String filepath = fileParameters.value();
  String encoding = fileParameters.encoding();
  if (filepath.indexOf(':') < 0) {
    return new InputStreamReader(new FileInputStream(filepath), encoding);
  }
  String protocol = filepath.substring(0, filepath.indexOf(':'));
  String filename = filepath.substring(filepath.indexOf(':') + 1);
  if ("classpath".equals(protocol)) {
    return new InputStreamReader(getClass().getClassLoader().getResourceAsStream(filename), encoding);
  } else if ("file".equals(protocol)) {
    return new InputStreamReader(new FileInputStream(filename), encoding);
  }
  throw new IllegalArgumentException("Unknown file access protocol. Only 'file' and 'classpath' are supported!");
}
origin: pl.pragmatists/JUnitParams

private Object[] paramsFromFile() {
  try {
    Reader reader = createProperReader();
    DataMapper mapper = fileParameters.mapper().newInstance();
    try {
      return mapper.map(reader);
    } finally {
      reader.close();
    }
  } catch (Exception e) {
    e.printStackTrace();
    throw new RuntimeException(
        "Could not successfully read parameters from file: " + fileParameters.value(), e);
  }
}
origin: tomekkaczanowski/junit-put-examples

@Test
//@FileParameters(value = "/home/tomek/book/github/put_2/src/test/resources/com/practicalunittesting/chp06/excel/financial_junitparams.csv", mapper= CsvWithHeaderMapper.class)
@FileParameters(value = "classpath:com/practicalunittesting/chp06/excel/financial_junitparams.csv", mapper= CsvWithHeaderMapper.class)
public void shouldCalculateDiscount(String value, String discount) {
  assertEquals(Double.parseDouble(discount),
      DiscountCalculator.calculateDiscount(Double.parseDouble(value)), 0.0001);
}
origin: tomekkaczanowski/junit-put-examples

  @Test
  //@FileParameters(value = "/home/tomek/book/github/put_2/src/test/resources/com/practicalunittesting/chp06/excel/financial_junitparams.csv", mapper= CsvWithHeaderMapper.class)
  @FileParameters(value = "classpath:com/practicalunittesting/chp06/excel/financial_junitparams.csv", mapper= CsvWithHeaderMapper.class)
  public void shouldCalculateDiscountDoubles(double value, double discount) {
    assertEquals(discount,
        DiscountCalculator.calculateDiscount(value), 0.0001);
  }
}
junitparamsFileParameters

Most used methods

  • <init>
  • encoding
  • mapper
  • value

Popular in Java

  • Making http post requests using okhttp
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now