From 509833cd8a72d672f2b150539cb62715ceda7832 Mon Sep 17 00:00:00 2001 From: binsky Date: Wed, 24 Nov 2021 10:30:18 +0100 Subject: [PATCH] add first test of test driven development project --- .idea/.gitignore | 8 +++++ .idea/compiler.xml | 13 +++++++ .idea/jarRepositories.xml | 20 +++++++++++ .idea/misc.xml | 14 ++++++++ .idea/runConfigurations.xml | 10 ++++++ .idea/vcs.xml | 6 ++++ pom.xml | 33 ++++++++++++++++++ src/main/java/BowlingGameCalculator.java | 5 +++ src/test/java/BowlingCalculatorTest.java | 30 ++++++++++++++++ target/classes/BowlingGameCalculator.class | Bin 0 -> 424 bytes .../test-classes/BowlingCalculatorTest.class | Bin 0 -> 1637 bytes 11 files changed, 139 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 pom.xml create mode 100644 src/main/java/BowlingGameCalculator.java create mode 100644 src/test/java/BowlingCalculatorTest.java create mode 100644 target/classes/BowlingGameCalculator.class create mode 100644 target/test-classes/BowlingCalculatorTest.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..878052f --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bc14d94 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9dbe251 --- /dev/null +++ b/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + org.example + bowling-kata + 1.0-SNAPSHOT + + + 14 + 14 + 5.8.1 + 1.8.1 + + + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + test + + + + \ No newline at end of file diff --git a/src/main/java/BowlingGameCalculator.java b/src/main/java/BowlingGameCalculator.java new file mode 100644 index 0000000..84210ca --- /dev/null +++ b/src/main/java/BowlingGameCalculator.java @@ -0,0 +1,5 @@ +public class BowlingGameCalculator { + public int score(String playerResult) { + return 0; + } +} diff --git a/src/test/java/BowlingCalculatorTest.java b/src/test/java/BowlingCalculatorTest.java new file mode 100644 index 0000000..edaedda --- /dev/null +++ b/src/test/java/BowlingCalculatorTest.java @@ -0,0 +1,30 @@ +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.aggregator.AggregateWith; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.CsvFileSource; +import org.junit.jupiter.params.provider.CsvSource; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class BowlingCalculatorTest { + + @ParameterizedTest(name = "[{index}] {0} scores {2}") + @MethodSource("playerResults") + void test(String testName, String playerResult, int expectedScore) { + BowlingGameCalculator bgc = new BowlingGameCalculator(); + + int calculatedScore = bgc.score(playerResult); + + assertEquals(expectedScore, calculatedScore, String.format("%s: %s", testName, playerResult)); + } + + private static Stream playerResults() { + return Stream.of(Arguments.of("worst game", "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0", 0)); // 16x 0 + } +} diff --git a/target/classes/BowlingGameCalculator.class b/target/classes/BowlingGameCalculator.class new file mode 100644 index 0000000000000000000000000000000000000000..069817af8d6daf884e483ab73b6e2f59abced272 GIT binary patch literal 424 zcmZutO-lnY5PjKCT~}MHRq*Dm_2Axmu;RgjA}k74de5$*rlcFm?kfH#FP;Ps{s4cJ zIN26@uz}2D-n=(6$ym%L|!oj=dzI11%un` zPeN=kbT9R*lEw6z&&7zVyjHx@hQS-@N5RlaWg%|sc_z#Q&lEA8ROehxxREwrl3w*B zONPUAZMPwVU*_77yW2}wTa7D2lZX8qhWJ_WH(~BYSu5JJ^Iydfjdg8uaV6~H{1?d#8~ry&^C44cN?*C Vx{dQ-QC&K%qK#eh&|@0?-X9RbRn7na literal 0 HcmV?d00001 diff --git a/target/test-classes/BowlingCalculatorTest.class b/target/test-classes/BowlingCalculatorTest.class new file mode 100644 index 0000000000000000000000000000000000000000..82ff973bfd02beec03d9fdbba9672b444a924058 GIT binary patch literal 1637 zcmb7EYje{^6g_KOmLo(1E_p#H?jx;43<{J-iPJ!m0yQKqY;B9SW+*PnK~WcVUfJx*-y90RsF zfUm~tflWoS_$6sDE%}sTp6w0;W8aHubH?$6xvW^&qPEbD6EAY z64rP_24X$#Z3*>^Z~1gmZiH>_x44qYK07Svmoh0|Ba`i6v>L(b6xA6en2F|Sz3Xm^ zp_F*6Q>~LLho#G$NI89{Zf!jVim>_ZSvV20T#HW1(M$on{!TwjfX=)hk6i8ayTbf|H5&m@+erHDx#8I!<1S zM<-h@eFUEab=Q`Ojx`|mKqkUCe{AiqCZ(fByhe{;^2vjuK#|68Y3I?*Xf`gt1N)s8 zIozNz`5PF=O&aZi0dCL0Lf85bvv@+ZdM z$Zh23n;V5{b025+F*&@Ti~>2H!x$#%U7Uu4ne?*d0pP)9F1_Eilz@vRS|u^K_#Vp? z#~3QOi+hBWAgs`tfmQl{imcYi=Z6UQ@qiW&H^CzO2#bF8jQfq005DrjS(aysX8E(` ghLPV#h3J00kLqs(#zyini$`>l!%uYDNLP>F16tauSpWb4 literal 0 HcmV?d00001