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

The following examples show how to use org.junit.jupiter.params.provider.CsvFileSource. These examples are extracted from open source projects. 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
@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 Project: jpeek   Source File: Lcom4Test.java    License: 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 Project: jpeek   Source File: MetricsTest.java    License: 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 Project: triplea   Source File: RemoteActionCodeTest.java    License: 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 Project: greenbot   Source File: DevTagAnalyzerTest.java    License: 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
@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 Project: journaldev   Source File: ParameterizedTests.java    License: 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
@ParameterizedTest
@CsvFileSource(resources = "/word-lengths.csv")
void withCsvFileSource(String word, int length) {
	assertEquals(length, word.length());
}
 
Example 9
Source Project: crawler-commons   Source File: BasicURLNormalizerTest.java    License: 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);
}