Browse Source

variant 1

parameterized_Tests
Thomas Papendieck 4 years ago
parent
commit
6ff9ba2ed9
  1. 37
      src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java

37
src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java

@ -0,0 +1,37 @@
package de.edu.hsfulda.ccip.tdd.purefunction.parameterized;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import java.util.stream.Stream;
import org.hamcrest.Matcher;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import de.edu.hsfulda.ccip.tdd.purefunction.BowlingCalculator;
public class BowlingCalculatorParameterized_1_SourceMethodTest {
static Stream<Arguments> sourceMethod() {
// arrange
return Stream.of(//
arguments("worst game", "-- -- -- -- -- -- -- -- -- --", equalTo(0)),
arguments("incomplete frames", "-1 23 -4 5- -6 -7 8- 9- -- --", equalTo(45)),
arguments("spares","-- -- 3/ -- 7/ -- -- -- -- --" , equalTo(20))
//
);
}
@ParameterizedTest(name = "#{index} - game type {0}")
@MethodSource("sourceMethod")
void testStreamSouce(String gameType, String rolls, Matcher<Integer> expectedResult) {
// act
int score = new BowlingCalculator().score(rolls);
//assert
assertThat(rolls, score, expectedResult);
}
}
Loading…
Cancel
Save