org.junit.jupiter.params.provider.CsvFileSource Java Examples

The following examples show how to use org.junit.jupiter.params.provider.CsvFileSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CsvFileSourceParameterizedTest.java    From Mastering-Software-Testing-with-JUnit-5 with MIT License 7 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/input.csv")
void testWithCsvFileSource(String first, int second) {
    System.out.println("Yet another parameterized test with (String) "
            + first + " and (int) " + second);

    assertNotNull(first);
    assertNotEquals(0, second);
}
 
Example #2
Source File: Lcom4Test.java    From jpeek with MIT License 7 votes vote down vote up
@ParameterizedTest
@Disabled
@CsvFileSource(resources = "/org/jpeek/calculus/java/lcom4-params.csv")
public void calculatesValue(final String file, final String value) throws Exception {
    final XML result = new Lcom4().node(
        "", new HashMap<>(0), new Skeleton(
            new FakeBase(file)
        ).xml()
    );
    new Assertion<>(
        "Must create LCOM4 value",
        new ItemAt<>(0, result.xpath("/metric/app/package/class/@value")),
        new ScalarHasValue<>(value)
    ).affirm();
}
 
Example #3
Source File: MetricsTest.java    From jpeek with MIT License 7 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/org/jpeek/metricstest-params.csv")
public void testsTarget(final String target, final String metric, final double value,
    @TempDir final Path output)
    throws Exception {
    new XslReport(
        new Skeleton(new FakeBase(target)).xml(), new XslCalculus(),
        new ReportData(metric)
    ).save(output);
    final String xpath;
    if (Double.isNaN(value)) {
        xpath = "//class[@id='%s' and @value='NaN']";
    } else {
        xpath = "//class[@id='%s' and number(@value)=%.4f]";
    }
    new Assertion<>(
        new FormattedText(
            "Must exists with target '%s' and value '%s'",
            target, value
        ).asString(),
        XhtmlMatchers.xhtml(
            new TextOf(
                output.resolve(String.format("%s.xml", metric))
            ).asString()
        ),
        XhtmlMatchers.hasXPaths(
            String.format(
                xpath,
                target, value
            )
        )
    ).affirm();
}
 
Example #4
Source File: RemoteActionCodeTest.java    From triplea with GNU General Public License v3.0 7 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/required-op-codes.csv")
void verifyCorrectOpCode(
    final int opCode, @AggregateWith(MethodAggregator.class) final Method method) {
  final RemoteActionCode remoteActionCode = method.getAnnotation(RemoteActionCode.class);

  assertThat(
      "Expected @RemoteActionCode annotation to be present for " + method,
      remoteActionCode,
      is(notNullValue()));

  assertThat("Invalid value for " + method, remoteActionCode.value(), is(opCode));
}
 
Example #5
Source File: DevTagAnalyzerTest.java    From greenbot with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/dev-tags.csv")
void withCsvSource(String key, String value, Boolean outcome) {
    Tag tag = Tag.builder().key(key).value(value).build();
    assertEquals(outcome, devTagAnalyzer.isDevTagPresent(Arrays.asList(tag)));
}
 
Example #6
Source File: CsvFileSourceParameterizedTest.java    From mastering-junit5 with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/input.csv")
void testWithCsvFileSource(String first, int second) {
    System.out.println("Yet another parameterized test with (String) "
            + first + " and (int) " + second);

    assertNotNull(first);
    assertNotEquals(0, second);
}
 
Example #7
Source File: ParameterizedTests.java    From journaldev with MIT License 6 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/country_code.csv", numLinesToSkip = 1)
void test_CsvFileSource(String country, int code) {
    assertNotNull(country);
    assertTrue(0 < code);
}
 
Example #8
Source File: ArgumentSourcesTest.java    From demo-junit-5 with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/word-lengths.csv")
void withCsvFileSource(String word, int length) {
	assertEquals(length, word.length());
}
 
Example #9
Source File: BasicURLNormalizerTest.java    From crawler-commons with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@CsvFileSource(resources = "/normalizer/weirdToNormalizedUrls.csv")
void testBasicNormalizer(String weirdUrl, String expectedNormalizedUrl) throws Exception {
  Assertions.assertEquals(expectedNormalizedUrl, normalizer.filter(weirdUrl), "normalizing: " + weirdUrl);
}