Browse Source

variant 3

parameterized_Tests
Thomas Papendieck 4 years ago
parent
commit
5a86e1e457
  1. 20
      src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_3_CsvFileTest.java
  2. 3
      src/test/resources/gameSamples.csv

20
src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_3_CsvFileTest.java

@ -0,0 +1,20 @@
package de.edu.hsfulda.ccip.tdd.purefunction.parameterized;
import static org.junit.Assert.assertThat;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import de.edu.hsfulda.ccip.tdd.purefunction.BowlingCalculator;
public class BowlingCalculatorParameterized_3_CsvFileTest {
@ParameterizedTest(name = "#{index} - game type {0}")
@CsvFileSource(resources = "/gameSamples.csv",numLinesToSkip = 1)
void testStreamSouceMulti(String gameType, String rolls, int expectedResult) {
int score = new BowlingCalculator().score(rolls);
assertThat(rolls, score, CoreMatchers.equalTo(expectedResult));
}
}

3
src/test/resources/gameSamples.csv

@ -0,0 +1,3 @@
test name , sample rolls , expected
"worst game" ,"-- -- -- -- -- -- -- -- -- --", 0
"incomplete frames","-1 23 -4 5- -6 -7 8- 9- -0 --", 45
Loading…
Cancel
Save