I am trying to run a parametrized test from CSV-file.
It is working if I use just CSVSource like that:
@ParameterizedTest
@CsvSource({ "a,A", "b,B" })
void csvSourceTest(String input, String expected) {
String actualValue = input.toUpperCase();
assertEquals(expected, actualValue);
}
But if I try the same thing from a file it won't work:
@ParameterizedTest
@CsvFileSource(resources = "/data.csv")
void csvFileSourceTest(String input, String expected) {
String actualValue = input.toUpperCase();
assertEquals(expected, actualValue);
}
I have also tried using a hard path to my file but for the file test in Eclipse I always get the message
No tests found with test runnter 'JUnit 5'.
Where does JUnit expect the file?
These are my dependencies:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
Does anybody know what I might be missing or where the error is?
Thanks in advance
PAUL
The JUnit5 user guide states that the CSV file needs to be on the classpath. In case of a Maven project that would be src/test/resources
.