Compare commits

...

8 Commits

Author SHA1 Message Date
Thomas Papendieck 49e8fa8452 automatic merge 4 years ago
Thomas Papendieck 59a3884b5f next run 4 years ago
Thomas Papendieck 6dad3723c7 trigger other branch 4 years ago
Thomas Papendieck 31f57299ec trigger jenkins 4 years ago
Thomas Papendieck 5a86e1e457 variant 3 4 years ago
Thomas Papendieck 1a01dd963d variant 2 4 years ago
Thomas Papendieck 6ff9ba2ed9 variant 1 4 years ago
Thomas Papendieck 8d7f5a2c8b jupiter-params dependency added 4 years ago
  1. 8
      pom.xml
  2. 37
      src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_1_SourceMethodTest.java
  3. 23
      src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_2_CsvTest.java
  4. 20
      src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_3_CsvFileTest.java
  5. 3
      src/test/resources/gameSamples.csv
  6. 4
      test.txt

8
pom.xml

@ -13,7 +13,7 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<version>5.7.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -22,6 +22,12 @@
<version>1.5.2</version> <version>1.5.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>

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);
}
}

23
src/test/java/de/edu/hsfulda/ccip/tdd/purefunction/parameterized/BowlingCalculatorParameterized_2_CsvTest.java

@ -0,0 +1,23 @@
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.CsvSource;
import de.edu.hsfulda.ccip.tdd.purefunction.BowlingCalculator;
public class BowlingCalculatorParameterized_2_CsvTest {
@CsvSource({ //
"worst game , -- -- -- -- -- -- -- -- -- --, 0",
"incomplete frames, -1 23 -4 5- -6 -7 8- 9- -- --, 45" //
})
@ParameterizedTest(name = "#{index} - game type {0}")
void testStreamSouceMulti(String gameType, String rolls, int expectedResult) {
int score = new BowlingCalculator().score(rolls);
assertThat(rolls, score, CoreMatchers.equalTo(expectedResult));
}
}

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

4
test.txt

@ -0,0 +1,4 @@
test:
dhvösdhä
ädlöfhäasdfhö
fgösifduhvaud
Loading…
Cancel
Save