Created
March 22, 2018 23:42
-
-
Save igorstojanovski/9d7c0d89a2e5ccb13d6d0a54ccfc4db0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@TestFactory | |
public Stream<DynamicTest> testFactory() { | |
InputStream inputFS = getClass().getClassLoader().getResourceAsStream("testData.csv"); | |
BufferedReader br = new BufferedReader(new InputStreamReader(inputFS)); | |
return br.lines().skip(1).map(mapCsvLineToDynamicTest()); | |
} | |
private Function<String, DynamicTest> mapCsvLineToDynamicTest() { | |
return s -> { | |
final String[] values = s.split(","); | |
return dynamicTest(values[0], () -> assertAddition(values)); | |
}; | |
} | |
private void assertAddition(String[] values) { | |
assertThat(Integer.parseInt(values[1]) + Integer.parseInt(values[2])) | |
.isEqualTo(Integer.parseInt(values[3])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment