diff --git a/.idea/misc.xml b/.idea/misc.xml index c0e11eb..e2f41df 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -8,7 +8,7 @@ - + \ No newline at end of file diff --git a/docs/BDD_DOCUMENTATION.md b/docs/BDD_DOCUMENTATION.md new file mode 100644 index 0000000..c2df595 --- /dev/null +++ b/docs/BDD_DOCUMENTATION.md @@ -0,0 +1,401 @@ +** +# BDD DOKUMENTÁCIÓ +** + +## A feladat részei + +A feladatot három fázisra osztottam fel: + +1. A tesztelendő funkciók meghatározása +2. A tesztelendő funkciók specifikációja a BDD szabályai szerint +3. A specifikált esetek implementálása + +## Tesztelendő funkciók + +Teszteseteknek nyolc olyan alapvető funckiót választottam, amelyek helyes működése a játék szempontjából igencsak fontos/alapvető/elengedhetetlen. Ezek vegyes komplexitásúak: vannak köztük igazán egyszerűek (pl. passzolás), de olyanok is, ahol akár 3-4 forgatókönyv is előállhat (mozgás, pumpa összeszedése). A fő aktorok is igen változatosak: *Mechanic, Saboteur, Player, Cistern* és *Pump* fókuszú tesztek is megtalálhatóak a választott funkciók között. + +** + +1. Mechanic standing on a punctured pipe attempts to fix it +2. Player passes their turn +3. Player standing on a pipe attempts to puncture it +4. Cistern attempts to generate a pump +5. Mechanic attempts to collect a pump from a cistern +6. Saboteur standing on a pipe attempts to make it slippery +7. A pump experiences a breakdown +8. Player attempts to move from a pipe to one of its neighbouring components + +## Tesztek specifikációja + +A tesztek specifikációja a BDD szabványt követi. Egy címmel (*Title*) kezdődik, majd a fő aktor és a teszt céljának bemutatása következik (*As a, I want, so that*). Ezután a különböző esetek (*Scenario*) leírása következik. Itt először megadjuk az előfeltételeket (*Given, and*), majd a cselekvést (*when*), végül pedig az elvárt eredményt (*then*). + +** + +**Title: Mechanic standing on a punctured pipe attempts to fix it.** + + As a Mechanic, + I want to be able to fix punctured pipes while standing on them, + so that they become functional again. + +**Scenario 1:** A Mechanic with enough AP fixes a punctured pipe while standing on it. + + Given that a pipe has been punctured + and I am a Mechanic + and I am standing on the pipe + and I have enough AP, + when I fix the pipe, + then it should be functional again. + +**Scenario 2:** A Mechanic without enough AP attempts to fix a punctured pipe while standing on it. + + Given that a pipe has been punctured + and I am a Mechanic + and I am standing on the pipe + and I don't have enough AP, + when I try to fix the pipe, + then the pipe shouldn't be fixed. + +--- + +**Title: Player passes their turn.** + + As a Player, + I want to be able to pass my turn, + so that my turn ends and the next player can start theirs. + +**Scenario 1:** A Player passes their turn. + + Given that I am the active player, + when I pass my turn, + then my turn should be over. + +--- + +**Title: Player standing on a pipe attempts to puncture it.** + + As a Player, + I want to be able to puncture pipes while standing on them, + so that they become non-functional. + +**Scenario 1:** A Player with enough AP punctures a working pipe while standing on it. + + Given that a pipe is working + and I am standing on the pipe + and I have enough AP, + when I puncture the pipe, + then it should be punctured. + +**Scenario 2:** A Player without enough AP attempts to puncture a working pipe while standing on it. + + Given that a pipe is working + and I am standing on the pipe + and I don't have enough AP, + when I attempt to puncture the pipe, + then the pipe shouldn't get punctured. + +**Scenario 3:** A Player without enough AP attempts to puncture a broken pipe while standing on it. + + Given that a pipe is punctured + and I am standing on the pipe + and I have enough AP, + when I attempt to puncture the pipe, + then the pipe shouldn't be punctured again. + +--- + +**Title: Cistern attempts to generate a pump.** + + As a Cistern, + I want to be able to generate pumps (one at a time), + so that they can be pe picked up and placed down by Mechanics. + +**Scenario 1:** A Cistern with no pump on it successfully generates a pump. + + Given that I am a Cistern + and I have no generated pumps, + when it is time to generate a pump, + then the pump should get generated. + +**Scenario 2:** A cistern with a pump on it already attempts to generate another one. + + Given that I am a Cistern + and I already have a generated pump, + when it is time to generate a pump, + then the pump shouldn't get generated. + +--- + +**Title: Mechanic attempts to collect a pump from a cistern.** + + As a Mechanic, + I want to be able to collect generated pumps (one at a time) from cisterns while standing on them, + so that I can later place them down on the map. + +**Scenario 1:** A Mechanic with enough AP and an empty inventory collects a pump from a cistern that has a generated pump. + + Given that a cistern has a generated pump + and I am a Mechanic + and I am standing on the cistern + and my inventory is empty + and I have enough AP, + when I attempt to collect the pump, + then the pump should be collected. + +**Scenario 2:** A Mechanic without enough AP and an empty inventory attempts to collect a pump from a cistern that has a generated pump. + + Given that a cistern has a generated pump + and I am a Mechanic + and I am standing on the cistern + and my inventory is empty + and I don't have enough AP, + when I attempt to collect the pump, + then the pump shouldn't be collected. + +**Scenario 3:** A Mechanic with a non-empty inventory attempts to collect a pump from a cistern that has a generated pump. + + Given that a cistern has a generated pump + and I am a Mechanic + and I am standing on the cistern + and my inventory is not empty, + when I attempt to collect the pump, + then the pump shouldn't be collected. + +**Scenario 4:** A Mechanic with enough AP and an empty inventory attempts to collect a pump from a cistern that doesn't have a generated pump. + + Given that a cistern has no generated pumps + and I am a Mechanic + and I am standing on the cistern + and my inventory is empty + and I have enough AP, + when I attempt to collect the pump, + then there is no pump to collect. + +--- + +**Title: Saboteur standing on a pipe attempts to make it slippery** + + As a Saboteur, + I want to be able to make pipes slippery, + so that other players will not be able to stay on them. + +**Scenario 1:** A Saboteur with enough AP standing on a non-slippery pipe makes it slippery. + + Given that a pipe is not slippery + and I am a Saboteur + and I am standing on the pipe + and I have enough AP, + when I attempt to make the pipe slippery, + then the pipe should get slippery. + +**Scenario 2:** A Saboteur standing on a slippery pipe attempts to make it slippery again. + + Given that a pipe is slippery + and I am a Saboteur + and I am standing on the pipe + and I have enough AP, + when I attempt to make the pipe slippery, + then nothing should happen, as the pipe is already slippery. + +**Scenario 3:** A Saboteur without enough AP standing on a pipe attempts to make it slippery. + + Given that I am standing on a pipe + and I am a Saboteur + and I don't have enough AP, + when I attempt to make the pipe slippery, + then the pipe shouldn't get slippery. + +--- + +**Title: A pump experiences a breakdown.** + + As a Pump, + I want to sometimes break down and become non-functional, + so that I provide an extra challenge for the players. + +**Scenario 1:** A functioning pump breaks down. + + Given that I am a pump + and I am functional, + when I experience a breakdown, + then I should become non-functional. + +**Scenario 2:** A non-functioning pump breaks down. + + Given that I am a pump + and I am non-functional, + when I experience a breakdown, + then nothing happens, as I am already broken. + +--- + +**Title: Player attempts to move from a pipe to one of its neighbouring components.** + + As a Player, + I want to be able to move from pipes to one of their neighbouring components. + +**Scenario 1:** A non-stuck Player standing on a pipe with enough AP moves to a valid neighbouring component. + + Given that I am standing on a pipe + and I am not stuck + and I have enough AP + and I intend to move to an existing neighbour, + when I attempt to move to the selected component, + then the movement should be successful. + +**Scenario 2:** A stuck Player standing on a pipe attempts to move to a valid neighbouring component. + + Given that I am standing on a pipe + and I am stuck + and I intend to move to an existing neighbour, + when I attempt to move to the selected component, + then the movement should be unsuccessful. + +**Scenario 3:** A non-stuck Player standing on a pipe without enough AP attempts to move to a valid neighbouring component. + + Given that I am standing on a pipe + and I am not stuck + and I don't have enough AP + and I intend to move to an existing neighbour, + when I attempt to move to the selected component, + then the movement should be unsuccessful. + +**Scenario 4:** A Player standing on a pipe attempts to move to a non-existent neighbouring component. + + Given that I am standing on a pipe + and I intend to move to a non-existing neighbour, + when I attempt to move to the selected component, + then the movement should be unsuccessful. + +## Tesztek implementációjának folyamata + +Elkészült a specifikáció, itt az ideje implementálni. Ehhez az egyik legnépszerűbb BDD implementációs szoftvert, a `Cucumber`-t fogom használni. Java fejlesztőkörnyezetnek az `IntelliJ IDEA`-t választottam. + +**Cucumber setup-olása** + +A `Cucumber` használatához szükség van `Maven` (vagy `Gradle`) setup-olására. Ez az #1 számú Issue-ban megtörtént, és mivel az Issue-hoz tartozó branch be lett mergelve a `main`-be, ezért nekem csupán annyi volt a dolgom, hogy rebaseljem a branchemet a `main`-re, majd a `pom.xml` fájlban felvegyem dependency-k közé a `Cucumber` legfrissebb (7.17.0) verzióját: + +![Cucumber dependency](images/cucumberdependency.png) + +Ezek után el is kezdhettem a tesztek implementálását. + +**Feature file-ok elkészítése és feltöltése** + +A teszteléshez szükséges `.feature` fájlokat a `src > test > resources` mappában hozom létre, mind a 8 tesztelendő funkciónak külön fájlt biztosítva. Ezekbe a fájlokba bemásolom a specifikált teszteseteket, majd egy-két helyen módosítom őket, hogy a fordító számára értelmezhető legyen a bemenet (sorok elején nagy kezdőbetű, Title helyett Feature, Scenario-k sorszámának törlése, egyéb kis formázások). + +Végeredményül az alábbi fájlokat kapom: + +![Feature files](images/featurefiles.png) + +Eljött az idő a lépések definiáláshoz. + +**Lépésdefiníciók megírása** + +Az IntelliJ segítségével szerencsére egyszerűen legenerálható a `StepDefinitions.java` file, amely már tartalmazza az implementálandó lépések vázát (illetve új lépések is könnyen hozzáadhatók). Ezekben a generált függvényekben megírom a szükséges lépések implementációját. A függvényekbe kerülhetnek a CmdInterpreter osztály megfelelő parancsvégrehajtásai, értékadás segédváltozóknak (pl. aktív játékos eltárolása), illetve a *Then* típusú függvényekbe a a jUnit-ból már ismert *assertEquals* / *assertTrue*, amelyek segítségével ellenőrzni tudom, hogy a lépések eredményeként az elvárt kimenetet kapjuk-e. Extra lépésként kicsit módosítok a feature fájlokban definiált prekondíciók közül is néhányon (vagy a sorrendjükön), hogy csökkentsem a redundanciát. Pl.: a specifikációban különböző eseteknél az "I fix the pipe" és az "I try to fix the pipe" lépés is megtalálható, de mivel mindkettő esetén ugyanaz a parancs hajtódik végre a háttérben, ezért elég hogyha csak az egyik szerepel a feature fájlban. + +**Tesztek futtatása** + +Miután egy funkció feature file-ja és a mögöttes lépésdefiníciók is rendelkezésre állnak, futtathatjuk az adott tesztet az IntelliJ segítségével. Ehhez egyszerűen jobb egérgombbal rákattintok a teszthez tartozó `.feature` file-ra, majd a megjelenő menüben a `"Run: Feature (...)"` opciót választom: + +![Run BDD test](images/runbddtest.png) + +Ekkor (hogyha mindent jól csináltam) megjelenik egy `Test Result` terminál ablak, ahol láthatom a teszt futásának eredményét: + +![BDD test results](images/bddtestresults.png) + +Ha a teszt futása sikertelen (pl. elírtam a CmdInterpreter valamelyik parancsát), akkor a terminálnak valami ilyesmit kell mutatnia: + +![Failed BDD test](images/failedbddtest.png) + +**Eredmények** + +Az összes tesztet lefuttattam, az esetlegesen felmerülő hibákat kijavítottam. Végeredményül az alábbi resultokat kaptam az egyes tesztek futtatása után: + + mechanic_fixes_pipe.feature + +> Testing started at 4:05 ... +> +> 2 Scenarios (2 passed) +> 12 Steps (12 passed) +> 0m0.263s +> +> Process finished with exit code 0 + + player_passes.feature + +> Testing started at 4:07 ... +> +> 1 Scenarios (1 passed) +> 3 Steps (3 passed) +> 0m0.250s +> +> Process finished with exit code 0 + + player_punctures_pipe.feature + +> Testing started at 4:08 ... +> +> 3 Scenarios (3 passed) +> 15 Steps (15 passed) +> 0m0.313s +> +> Process finished with exit code 0 + + cistern_generates_pump.feature + +> Testing started at 4:03 ... +> +> 2 Scenarios (2 passed) +> 8 Steps (8 passed) +> 0m0.265s +> +> Process finished with exit code 0 + + mechanic_collects_pump.feature + +> Testing started at 4:04 ... +> +> 4 Scenarios (4 passed) +> 27 Steps (27 passed) +> 0m0.282s +> +> Process finished with exit code 0 + + saboteur_makes_pipe_slippery.feature + +> Testing started at 4:10 ... +> +> 3 Scenarios (3 passed) +> 18 Steps (18 passed) +> 0m0.331s +> +> Process finished with exit code 0 + + pump_breaks_down.feature + +> Testing started at 4:09 ... +> +> 2 Scenarios (2 passed) +> 8 Steps (8 passed) +> 0m0.269s +> +> Process finished with exit code 0 + + player_moves_from_pipe.feature + +> Testing started at 4:06 ... +> +> 4 Scenarios (4 passed) +> 21 Steps (21 passed) +> 0m0.286s +> +> Process finished with exit code 0 + +**Tanulság** + +Én korábban még nem foglalkoztam BDD tesztek írásával, ezért ez az egész folyamat egy új élmény volt számomra. Forgatókönyveket már kellett írnom korábban, így azok kigondolása és átültetése BDD specifikációs formátumba nem okozott különösebb gondot. jUnit teszteket is írtam már, ezért az implementáció sem volt problémás, azonban mindenképpen egy új élmény volt, hogy ezt a két tevékenységet ilyen módon kombinálhattam és végeredményül működő teszteket kaptam. Azt meg kell jegyeznem, hogy a Maven + jUnit setupolása az #1-es Issue-ban nagyban hozzájárult ahhoz, hogy én is gördülékenyen tudtam a munkámat végezni, ehhez jó csapatmunkára volt szükség. + +Összeségében engem megnyert a BDD tesztelés, elképzelhetőnek tartom, hogy a jövőben is alkalmazni fogom más projekteken. + +--- +> *Készítette: Czímer Bende* + diff --git a/docs/images/bddtestresults.png b/docs/images/bddtestresults.png new file mode 100644 index 0000000..fcbe8f8 Binary files /dev/null and b/docs/images/bddtestresults.png differ diff --git a/docs/images/cucumberdependency.png b/docs/images/cucumberdependency.png new file mode 100644 index 0000000..59d2681 Binary files /dev/null and b/docs/images/cucumberdependency.png differ diff --git a/docs/images/failedbddtest.png b/docs/images/failedbddtest.png new file mode 100644 index 0000000..8a6e3d1 Binary files /dev/null and b/docs/images/failedbddtest.png differ diff --git a/docs/images/featurefiles.png b/docs/images/featurefiles.png new file mode 100644 index 0000000..b3abc50 Binary files /dev/null and b/docs/images/featurefiles.png differ diff --git a/docs/images/runbddtest.png b/docs/images/runbddtest.png new file mode 100644 index 0000000..afa52ee Binary files /dev/null and b/docs/images/runbddtest.png differ diff --git a/pom.xml b/pom.xml index a815642..4556767 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,13 @@ 5.7.0 test + + + io.cucumber + cucumber-java + 7.17.0 + test + diff --git a/src/test/java/StepDefinitions.java b/src/test/java/StepDefinitions.java new file mode 100644 index 0000000..91ea1c4 --- /dev/null +++ b/src/test/java/StepDefinitions.java @@ -0,0 +1,306 @@ +import io.cucumber.java.Before; +import io.cucumber.java.en.And; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + +import java.util.Objects; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class StepDefinitions { + + CmdInterpreter cmd = new CmdInterpreter(); + String activePlayer = ""; + String activeComponent = ""; + String testResult = ""; + String neighbourComponent = ""; + + @Before + public void setup() { + cmd.NewCommand("Load:testmap.txt"); + activePlayer = ""; + activeComponent = ""; + testResult = ""; + neighbourComponent = ""; + } + + @Given("that a pipe has been punctured") + public void thatAPipeHasBeenPunctured() { + activeComponent = "pi1"; + cmd.NewCommand("ChangeBreakState:"+activeComponent+",broken"); + } + + @And("I am a Mechanic") + public void iAmAMechanic() { + activePlayer = "me1"; + } + + @And("I am standing on the pipe") + public void iAmStandingOnThePipe() { + if(Objects.equals(activePlayer, "")) + { + activePlayer = "me1"; + } + activeComponent = "pi1"; + cmd.NewCommand("SetPlayerPos:"+activePlayer+","+activeComponent); + } + + @And("I have enough AP") + public void iHaveEnoughAP() { + cmd.NewCommand("SetAP:"+activePlayer+",10"); + } + + @When("I fix the pipe") + public void iFixThePipe() { + testResult = cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",fix"); + } + + @Then("it should be functional again") + public void itShouldBeFunctionalAgain() { + assertEquals("[SIKERES] A(z) "+activePlayer+" jatekos megszerelte a komponenst, amin all", testResult); + } + + @And("I don't have enough AP") + public void iDonTHaveEnoughAP() { + cmd.NewCommand("SetAP:"+activePlayer+",0"); + } + + @Then("the pipe shouldn't be fixed") + public void thePipeShouldnTBeFixed() { + assertEquals("[HIBA] A jatekosnak nincs eleg AP-je a muvelet elvegzesehez!", testResult); + } + + @Given("that I am the active player") + public void thatIAmTheActivePlayer() { + activePlayer = "me1"; + } + + @When("I pass my turn") + public void iPassMyTurn() { + testResult = cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",pass"); + } + + @Then("my turn should be over") + public void myTurnShouldBeOver() { + assertEquals("[SIKERES] A(z) "+activePlayer+" jatekos passzolt", testResult); + } + + @Given("that I am a Cistern") + public void thatIAmACistern() { + activeComponent = "ci1"; + } + + @And("I have no generated pumps") + public void iHaveNoGeneratedPumps() { + cmd.NewCommand("ToggleRandom:false"); //véletlenszerű eventek letiltása, a ciszternán így nem generálódhat pumpa + } + + @When("it is time to generate a pump") + public void itIsTimeToGenerateAPump() { + testResult = cmd.NewCommand("GeneratePump:"+activeComponent); + } + + @Then("the pump should get generated") + public void thePumpShouldGetGenerated() { + assertEquals("[SIKERES]: Pumpa sikeresen legeneralva!", testResult); + } + + @And("I already have a generated pump") + public void iAlreadyHaveAGeneratedPump() { + cmd.NewCommand("GeneratePump:"+activeComponent); + } + + @Then("the pump shouldn't get generated") + public void thePumpShouldnTGetGenerated() { + assertEquals("[HIBA]: nem lehet letrehozni a pumpat a "+activeComponent+" komponensen, mert mar van rajta egy masik", testResult); + } + + @Given("that a cistern has a generated pump") + public void thatACisternHasAGeneratedPump() { + activeComponent = "ci1"; + cmd.NewCommand("GeneratePump:"+activeComponent); + } + + @And("I am standing on the cistern") + public void iAmStandingOnTheCistern() { + activePlayer = "me1"; + cmd.NewCommand("SetPlayerPos:"+activePlayer+","+activeComponent); + } + + @And("my inventory is empty") + public void myInventoryIsEmpty() { + cmd.NewCommand("SetPlayerPos:"+activePlayer+",pi3"); //Player gets moved to a Pipe + cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",place"); //Player attempts to place down pump (if he has a pump, it will be placed down, so now his inventory is empty) + cmd.NewCommand("SetPlayerPos:"+activePlayer+","+activeComponent); //Player gets moved back to the Cistern + } + + @When("I attempt to collect the pump") + public void iAttemptToCollectThePump() { + testResult = cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",collect"); + } + + @Then("the pump should be collected") + public void thePumpShouldBeCollected() { + assertEquals("[SIKERES] A(z) "+activePlayer+" jatekos osszeszedett egy pumpat", testResult); + } + + @Then("the pump shouldn't be collected") + public void thePumpShouldnTBeCollected() { + assertTrue(testResult.contains("[HIBA]")); + } + + @And("my inventory is not empty") + public void myInventoryIsNotEmpty() { + cmd.NewCommand("SetItem:"+activePlayer); + } + + @Given("that a cistern has no generated pumps") + public void thatACisternHasNoGeneratedPumps() { + cmd.NewCommand("ToggleRandom:false"); //véletlenszerű eventek letiltása, a ciszternán így nem generálódhat pumpa + activeComponent = "ci1"; + } + + @Then("there is no pump to collect") + public void thereIsNoPumpToCollect() { + assertEquals("[HIBA] A jatekos jelenlegi poziciojan nincs generalt pumpa!", testResult); + } + + @Given("that a pipe is not slippery") + public void thatAPipeIsNotSlippery() { + activeComponent = "pi1"; + cmd.NewCommand("ChangePipeState:"+activeComponent+",Normal"); + } + + @And("I am a Saboteur") + public void iAmASaboteur() { + activePlayer = "sa1"; + } + + @When("I attempt to make the pipe slippery") + public void iAttemptToMakeThePipeSlippery() { + testResult = cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",slippery"); + } + + @Then("the pipe should get slippery") + public void thePipeShouldGetSlippery() { + assertEquals("[SIKERES] A(z) "+activePlayer+" jatekos csuszossa tette a komponenst, amin all", testResult); + } + + @Given("that a pipe is slippery") + public void thatAPipeIsSlippery() { + activeComponent = "pi1"; + cmd.NewCommand("ChangePipeState:"+activeComponent+",Slippery"); + } + + @Then("nothing should happen, as the pipe is already slippery") + public void nothingShouldHappenAsThePipeIsAlreadySlippery() { + assertEquals("[HIBA] Ez a tipusu komponens nem teheto csuszossa! (Elvart: Pipe)", testResult); //Egy picit csalóka, de ez a helyes hibaüzenet + } + + @Then("the pipe shouldn't get slippery") + public void thePipeShouldnTGetSlippery() { + assertEquals("[HIBA] A jatekosnak nincs eleg AP-je a muvelet elvegzesehez!", testResult); + } + + @Given("that I am a pump") + public void thatIAmAPump() { + activeComponent = "pu1"; + } + + @And("I am functional") + public void iAmFunctional() { + cmd.NewCommand("ChangeBreakState:"+activeComponent+",breakable"); + } + + @When("I experience a breakdown") + public void iExperienceABreakdown() { + testResult = cmd.NewCommand("BreakPump:"+activeComponent); + } + + @Then("I should become non-functional") + public void iShouldBecomeNonFunctional() { + assertEquals("[SIKERES] "+activeComponent+" komponens elrontva", testResult); + } + + @And("I am non-functional") + public void iAmNonFunctional() { + cmd.NewCommand("ChangeBreakState:"+activeComponent+",broken"); + } + + @Then("nothing happens, as I am already broken") + public void nothingHappensAsIAmAlreadyBroken() { + assertEquals("[HIBA] "+activeComponent+" nem rontható el, mivel már elromlott", testResult); + } + + @Given("that I intend to move to an existing neighbour") + public void thatIIntendToMoveToAnExistingNeighbour() { + activePlayer = "me1"; + neighbourComponent = "pu1"; + } + + @And("I am not stuck") + public void iAmNotStuck() { + cmd.NewCommand("UnstickPlayer:"+activePlayer); + } + + @When("I attempt to move to the selected component") + public void iAttemptToMoveToTheSelectedComponent() { + testResult = cmd.NewCommand("MovePlayer:"+activePlayer+","+neighbourComponent); + } + + @Then("the movement should be successful") + public void theMovementShouldBeSuccessful() { + assertEquals("[SIKERES]: "+activePlayer+" sikeresen atlepett a "+neighbourComponent+" komponensre!", testResult); + } + + @And("I am stuck") + public void iAmStuck() { + cmd.NewCommand("MovePlayer:"+activePlayer+","+neighbourComponent); //Temporarily move player to neighbouring component + cmd.NewCommand("ChangePipeState:"+activeComponent+",Sticky"); //Turn the pipe sticky + cmd.NewCommand("MovePlayer:"+activePlayer+","+activeComponent); //Move player back to pipe, so he gets stuck + } + + @Then("the movement should be unsuccessful") + public void theMovementShouldBeUnsuccessful() { + assertTrue(testResult.contains("[HIBA]")); + } + + @And("that I intend to move to a non-existing neighbour") + public void thatIIntendToMoveToANonExistingNeighbour() { + neighbourComponent = "pu100"; + } + + @Given("that a pipe is working") + public void thatAPipeIsWorking() { + activeComponent = "pi1"; + cmd.NewCommand("ChangeBreakState:"+activeComponent+",breakable"); + } + + @When("I puncture the pipe") + public void iPunctureThePipe() { + testResult = cmd.NewCommand("PlayerSimpleAction:"+activePlayer+",puncture"); + } + + @Then("it should be punctured") + public void itShouldBePunctured() { + assertEquals("[SIKERES] A(z) " + activePlayer + " jatekos kiszurta a komponenst, amin all", testResult); + } + + @Then("the pipe shouldn't get punctured") + public void thePipeShouldnTGetPunctured() { + assertEquals("[HIBA] A jatekosnak nincs eleg AP-je a muvelet elvegzesehez!", testResult); + } + + @Given("that a pipe is punctured") + public void thatAPipeIsPunctured() { + activeComponent = "pi1"; + cmd.NewCommand("ChangeBreakState:"+activeComponent+",broken"); + } + + @Then("the pipe shouldn't be punctured again") + public void thePipeShouldnTBePuncturedAgain() { + assertEquals("[HIBA] A komponenst nem lehet kiszurni (vagy mar ki van szurva)!", testResult); + } +} diff --git a/src/test/resources/cistern_generates_pump.feature b/src/test/resources/cistern_generates_pump.feature new file mode 100644 index 0000000..8820b67 --- /dev/null +++ b/src/test/resources/cistern_generates_pump.feature @@ -0,0 +1,14 @@ +Feature: Cistern attempts to generate a pump. + As a Cistern, I want to be able to generate pumps (one at a time), so that they can be pe picked up and placed down by Mechanics. + + Scenario: A Cistern with no pump on it successfully generates a pump. + Given that I am a Cistern + And I have no generated pumps + When it is time to generate a pump + Then the pump should get generated + + Scenario: A cistern with a pump on it already attempts to generate another one. + Given that I am a Cistern + And I already have a generated pump + When it is time to generate a pump + Then the pump shouldn't get generated \ No newline at end of file diff --git a/src/test/resources/mechanic_collects_pump.feature b/src/test/resources/mechanic_collects_pump.feature new file mode 100644 index 0000000..52e0ca8 --- /dev/null +++ b/src/test/resources/mechanic_collects_pump.feature @@ -0,0 +1,37 @@ +Feature: Mechanic attempts to collect a pump from a cistern. + As a Mechanic, I want to be able to collect generated pumps (one at a time) from cisterns while standing on them, so that I can later place them down on the map. + + Scenario: A Mechanic with enough AP and an empty inventory collects a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I have enough AP + When I attempt to collect the pump + Then the pump should be collected + + Scenario: A Mechanic without enough AP and an empty inventory attempts to collect a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I don't have enough AP + When I attempt to collect the pump + Then the pump shouldn't be collected + + Scenario: A Mechanic with a non-empty inventory attempts to collect a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is not empty + When I attempt to collect the pump + Then the pump shouldn't be collected + + Scenario: A Mechanic with enough AP and an empty inventory attempts to collect a pump from a cistern that doesn't have a generated pump. + Given that a cistern has no generated pumps + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I have enough AP + When I attempt to collect the pump + Then there is no pump to collect \ No newline at end of file diff --git a/src/test/resources/mechanic_fixes_pipe.feature b/src/test/resources/mechanic_fixes_pipe.feature new file mode 100644 index 0000000..1317c1b --- /dev/null +++ b/src/test/resources/mechanic_fixes_pipe.feature @@ -0,0 +1,18 @@ +Feature: Mechanic standing on a punctured pipe attempts to fix it. + As a Mechanic, I want to be able to fix punctured pipes while standing on them, so that they become functional again. + + Scenario: A Mechanic with enough AP fixes a punctured pipe while standing on it. + Given that a pipe has been punctured + And I am a Mechanic + And I am standing on the pipe + And I have enough AP + When I fix the pipe + Then it should be functional again + + Scenario: A Mechanic without enough AP attempts to fix a punctured pipe while standing on it. + Given that a pipe has been punctured + And I am a Mechanic + And I am standing on the pipe + And I don't have enough AP + When I fix the pipe + Then the pipe shouldn't be fixed \ No newline at end of file diff --git a/src/test/resources/player_moves_from_pipe.feature b/src/test/resources/player_moves_from_pipe.feature new file mode 100644 index 0000000..4597390 --- /dev/null +++ b/src/test/resources/player_moves_from_pipe.feature @@ -0,0 +1,31 @@ +Feature: Player attempts to move from a pipe to one of its neighbouring components. + As a Player, I want to be able to move from pipes to one of their neighbouring components. + + Scenario: A non-stuck Player standing on a pipe with enough AP moves to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am not stuck + And I have enough AP + When I attempt to move to the selected component + Then the movement should be successful + + Scenario: A stuck Player standing on a pipe attempts to move to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am stuck + When I attempt to move to the selected component + Then the movement should be unsuccessful + + Scenario: A non-stuck Player standing on a pipe without enough AP attempts to move to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am not stuck + And I don't have enough AP + When I attempt to move to the selected component + Then the movement should be unsuccessful + + Scenario: A Player standing on a pipe attempts to move to a non-existent neighbouring component. + Given that I intend to move to a non-existing neighbour + And I am standing on the pipe + When I attempt to move to the selected component + Then the movement should be unsuccessful \ No newline at end of file diff --git a/src/test/resources/player_passes.feature b/src/test/resources/player_passes.feature new file mode 100644 index 0000000..ba1d9a9 --- /dev/null +++ b/src/test/resources/player_passes.feature @@ -0,0 +1,7 @@ +Feature: Player passes their turn. + As a Player, I want to be able to pass my turn, so that my turn ends and the next player can start theirs. + + Scenario: A Player passes their turn. + Given that I am the active player + When I pass my turn + Then my turn should be over \ No newline at end of file diff --git a/src/test/resources/player_punctures_pipe.feature b/src/test/resources/player_punctures_pipe.feature new file mode 100644 index 0000000..e25b65e --- /dev/null +++ b/src/test/resources/player_punctures_pipe.feature @@ -0,0 +1,23 @@ +Feature: Player standing on a pipe attempts to puncture it. + As a Player, I want to be able to puncture pipes while standing on them, so that they become non-functional. + + Scenario: A Player with enough AP punctures a working pipe while standing on it. + Given that a pipe is working + And I am standing on the pipe + And I have enough AP + When I puncture the pipe + Then it should be punctured + + Scenario: A Player without enough AP attempts to puncture a working pipe while standing on it. + Given that a pipe is working + And I am standing on the pipe + And I don't have enough AP + When I puncture the pipe + Then the pipe shouldn't get punctured + + Scenario: A Player without enough AP attempts to puncture a broken pipe while standing on it. + Given that a pipe is punctured + And I am standing on the pipe + And I have enough AP + When I puncture the pipe + Then the pipe shouldn't be punctured again \ No newline at end of file diff --git a/src/test/resources/pump_breaks_down.feature b/src/test/resources/pump_breaks_down.feature new file mode 100644 index 0000000..49771a5 --- /dev/null +++ b/src/test/resources/pump_breaks_down.feature @@ -0,0 +1,14 @@ +Feature: A pump experiences a breakdown. + As a Pump, I want to sometimes break down and become non-functional, so that I provide an extra challenge for the players. + + Scenario: A functioning pump breaks down. + Given that I am a pump + And I am functional + When I experience a breakdown + Then I should become non-functional + + Scenario: A non-functioning pump breaks down. + Given that I am a pump + And I am non-functional + When I experience a breakdown + Then nothing happens, as I am already broken \ No newline at end of file diff --git a/src/test/resources/saboteur_makes_pipe_slippery.feature b/src/test/resources/saboteur_makes_pipe_slippery.feature new file mode 100644 index 0000000..9fd3454 --- /dev/null +++ b/src/test/resources/saboteur_makes_pipe_slippery.feature @@ -0,0 +1,26 @@ +Feature: Saboteur standing on a pipe attempts to make it slippery + As a Saboteur, I want to be able to make pipes slippery, so that other players will not be able to stay on them. + + Scenario: A Saboteur with enough AP standing on a non-slippery pipe makes it slippery. + Given that a pipe is not slippery + And I am a Saboteur + And I am standing on the pipe + And I have enough AP + When I attempt to make the pipe slippery + Then the pipe should get slippery + + Scenario: A Saboteur standing on a slippery pipe attempts to make it slippery again. + Given that a pipe is slippery + And I am a Saboteur + And I am standing on the pipe + And I have enough AP + When I attempt to make the pipe slippery + Then nothing should happen, as the pipe is already slippery + + Scenario: A Saboteur without enough AP standing on a pipe attempts to make it slippery. + Given that a pipe is not slippery + And I am standing on the pipe + And I am a Saboteur + And I don't have enough AP + When I attempt to make the pipe slippery + Then the pipe shouldn't get slippery \ No newline at end of file diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 577fda8..c91cf41 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,24 +1,24 @@ -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsSpring.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Notifiable.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\SComponent.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsPipe.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsPump.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Cistern.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Scoreboard.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Saboteur.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Spring.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Pump.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GameKeyListener.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Map.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Pipe.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Graphics.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Mechanic.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Active.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsPlayer.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Main.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsMap.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Passive.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\MyFrame.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\PipeState.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\Player.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\main\java\GraphicsCistern.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Spring.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\SComponent.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Passive.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsSpring.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Notifiable.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsMap.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Graphics.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GameKeyListener.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Saboteur.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Scoreboard.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Pipe.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsPlayer.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Cistern.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsCistern.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\PipeState.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Player.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsPipe.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\MyFrame.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Map.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Pump.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Main.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Active.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\GraphicsPump.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\main\java\Mechanic.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst index bd4ba34..2c10c85 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -1,2 +1,3 @@ Tests.class CmdInterpreter.class +StepDefinitions.class diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index 516fb60..268a746 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -1,2 +1,2 @@ -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\test\java\CmdInterpreter.java -D:\Egyetem\Integrációs és ellenőrzési technikák\HF\iet-hf-2024-goon-squad\src\test\java\Tests.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\test\java\CmdInterpreter.java +D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\src\test\java\Tests.java diff --git a/target/surefire-reports/2024-05-17T16-53-11_124.dumpstream b/target/surefire-reports/2024-05-17T16-53-11_124.dumpstream new file mode 100644 index 0000000..fa2d88d --- /dev/null +++ b/target/surefire-reports/2024-05-17T16-53-11_124.dumpstream @@ -0,0 +1,5 @@ +# Created at 2024-05-17T16:53:14.493 +Boot Manifest-JAR contains absolute paths in classpath 'D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\target\test-classes' +Hint: -Djdk.net.URLClassPath.disableClassPathURLCheck=true +'other' has different root + diff --git a/target/surefire-reports/2024-05-18T02-05-45_597.dumpstream b/target/surefire-reports/2024-05-18T02-05-45_597.dumpstream new file mode 100644 index 0000000..f94efce --- /dev/null +++ b/target/surefire-reports/2024-05-18T02-05-45_597.dumpstream @@ -0,0 +1,5 @@ +# Created at 2024-05-18T02:05:45.875 +Boot Manifest-JAR contains absolute paths in classpath 'D:\sulie\uniXD\iet\iet-hf-2024-goon-squad\target\test-classes' +Hint: -Djdk.net.URLClassPath.disableClassPathURLCheck=true +'other' has different root + diff --git a/target/surefire-reports/TEST-Tests.xml b/target/surefire-reports/TEST-Tests.xml index 294a1fb..2310ddb 100644 --- a/target/surefire-reports/TEST-Tests.xml +++ b/target/surefire-reports/TEST-Tests.xml @@ -1,59 +1,59 @@ - + - - + - + - - + + - + - + - + - + - + - + - + - - + + - + + - + - + @@ -61,20 +61,20 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/target/surefire-reports/Tests.txt b/target/surefire-reports/Tests.txt index daba8d3..384a8d7 100644 --- a/target/surefire-reports/Tests.txt +++ b/target/surefire-reports/Tests.txt @@ -1,4 +1,4 @@ ------------------------------------------------------------------------------- Test set: Tests ------------------------------------------------------------------------------- -Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.199 s - in Tests +Tests run: 16, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.132 s - in Tests diff --git a/target/test-classes/CmdInterpreter.class b/target/test-classes/CmdInterpreter.class index 23d6a72..084e9a1 100644 Binary files a/target/test-classes/CmdInterpreter.class and b/target/test-classes/CmdInterpreter.class differ diff --git a/target/test-classes/StepDefinitions.class b/target/test-classes/StepDefinitions.class new file mode 100644 index 0000000..f5235f5 Binary files /dev/null and b/target/test-classes/StepDefinitions.class differ diff --git a/target/test-classes/cistern_generates_pump.feature b/target/test-classes/cistern_generates_pump.feature new file mode 100644 index 0000000..8820b67 --- /dev/null +++ b/target/test-classes/cistern_generates_pump.feature @@ -0,0 +1,14 @@ +Feature: Cistern attempts to generate a pump. + As a Cistern, I want to be able to generate pumps (one at a time), so that they can be pe picked up and placed down by Mechanics. + + Scenario: A Cistern with no pump on it successfully generates a pump. + Given that I am a Cistern + And I have no generated pumps + When it is time to generate a pump + Then the pump should get generated + + Scenario: A cistern with a pump on it already attempts to generate another one. + Given that I am a Cistern + And I already have a generated pump + When it is time to generate a pump + Then the pump shouldn't get generated \ No newline at end of file diff --git a/target/test-classes/mechanic_collects_pump.feature b/target/test-classes/mechanic_collects_pump.feature new file mode 100644 index 0000000..52e0ca8 --- /dev/null +++ b/target/test-classes/mechanic_collects_pump.feature @@ -0,0 +1,37 @@ +Feature: Mechanic attempts to collect a pump from a cistern. + As a Mechanic, I want to be able to collect generated pumps (one at a time) from cisterns while standing on them, so that I can later place them down on the map. + + Scenario: A Mechanic with enough AP and an empty inventory collects a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I have enough AP + When I attempt to collect the pump + Then the pump should be collected + + Scenario: A Mechanic without enough AP and an empty inventory attempts to collect a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I don't have enough AP + When I attempt to collect the pump + Then the pump shouldn't be collected + + Scenario: A Mechanic with a non-empty inventory attempts to collect a pump from a cistern that has a generated pump. + Given that a cistern has a generated pump + And I am a Mechanic + And I am standing on the cistern + And my inventory is not empty + When I attempt to collect the pump + Then the pump shouldn't be collected + + Scenario: A Mechanic with enough AP and an empty inventory attempts to collect a pump from a cistern that doesn't have a generated pump. + Given that a cistern has no generated pumps + And I am a Mechanic + And I am standing on the cistern + And my inventory is empty + And I have enough AP + When I attempt to collect the pump + Then there is no pump to collect \ No newline at end of file diff --git a/target/test-classes/mechanic_fixes_pipe.feature b/target/test-classes/mechanic_fixes_pipe.feature new file mode 100644 index 0000000..1317c1b --- /dev/null +++ b/target/test-classes/mechanic_fixes_pipe.feature @@ -0,0 +1,18 @@ +Feature: Mechanic standing on a punctured pipe attempts to fix it. + As a Mechanic, I want to be able to fix punctured pipes while standing on them, so that they become functional again. + + Scenario: A Mechanic with enough AP fixes a punctured pipe while standing on it. + Given that a pipe has been punctured + And I am a Mechanic + And I am standing on the pipe + And I have enough AP + When I fix the pipe + Then it should be functional again + + Scenario: A Mechanic without enough AP attempts to fix a punctured pipe while standing on it. + Given that a pipe has been punctured + And I am a Mechanic + And I am standing on the pipe + And I don't have enough AP + When I fix the pipe + Then the pipe shouldn't be fixed \ No newline at end of file diff --git a/target/test-classes/player_moves_from_pipe.feature b/target/test-classes/player_moves_from_pipe.feature new file mode 100644 index 0000000..4597390 --- /dev/null +++ b/target/test-classes/player_moves_from_pipe.feature @@ -0,0 +1,31 @@ +Feature: Player attempts to move from a pipe to one of its neighbouring components. + As a Player, I want to be able to move from pipes to one of their neighbouring components. + + Scenario: A non-stuck Player standing on a pipe with enough AP moves to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am not stuck + And I have enough AP + When I attempt to move to the selected component + Then the movement should be successful + + Scenario: A stuck Player standing on a pipe attempts to move to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am stuck + When I attempt to move to the selected component + Then the movement should be unsuccessful + + Scenario: A non-stuck Player standing on a pipe without enough AP attempts to move to a valid neighbouring component. + Given that I intend to move to an existing neighbour + And I am standing on the pipe + And I am not stuck + And I don't have enough AP + When I attempt to move to the selected component + Then the movement should be unsuccessful + + Scenario: A Player standing on a pipe attempts to move to a non-existent neighbouring component. + Given that I intend to move to a non-existing neighbour + And I am standing on the pipe + When I attempt to move to the selected component + Then the movement should be unsuccessful \ No newline at end of file diff --git a/target/test-classes/player_passes.feature b/target/test-classes/player_passes.feature new file mode 100644 index 0000000..ba1d9a9 --- /dev/null +++ b/target/test-classes/player_passes.feature @@ -0,0 +1,7 @@ +Feature: Player passes their turn. + As a Player, I want to be able to pass my turn, so that my turn ends and the next player can start theirs. + + Scenario: A Player passes their turn. + Given that I am the active player + When I pass my turn + Then my turn should be over \ No newline at end of file diff --git a/target/test-classes/player_punctures_pipe.feature b/target/test-classes/player_punctures_pipe.feature new file mode 100644 index 0000000..e25b65e --- /dev/null +++ b/target/test-classes/player_punctures_pipe.feature @@ -0,0 +1,23 @@ +Feature: Player standing on a pipe attempts to puncture it. + As a Player, I want to be able to puncture pipes while standing on them, so that they become non-functional. + + Scenario: A Player with enough AP punctures a working pipe while standing on it. + Given that a pipe is working + And I am standing on the pipe + And I have enough AP + When I puncture the pipe + Then it should be punctured + + Scenario: A Player without enough AP attempts to puncture a working pipe while standing on it. + Given that a pipe is working + And I am standing on the pipe + And I don't have enough AP + When I puncture the pipe + Then the pipe shouldn't get punctured + + Scenario: A Player without enough AP attempts to puncture a broken pipe while standing on it. + Given that a pipe is punctured + And I am standing on the pipe + And I have enough AP + When I puncture the pipe + Then the pipe shouldn't be punctured again \ No newline at end of file diff --git a/target/test-classes/pump_breaks_down.feature b/target/test-classes/pump_breaks_down.feature new file mode 100644 index 0000000..49771a5 --- /dev/null +++ b/target/test-classes/pump_breaks_down.feature @@ -0,0 +1,14 @@ +Feature: A pump experiences a breakdown. + As a Pump, I want to sometimes break down and become non-functional, so that I provide an extra challenge for the players. + + Scenario: A functioning pump breaks down. + Given that I am a pump + And I am functional + When I experience a breakdown + Then I should become non-functional + + Scenario: A non-functioning pump breaks down. + Given that I am a pump + And I am non-functional + When I experience a breakdown + Then nothing happens, as I am already broken \ No newline at end of file diff --git a/target/test-classes/saboteur_makes_pipe_slippery.feature b/target/test-classes/saboteur_makes_pipe_slippery.feature new file mode 100644 index 0000000..9fd3454 --- /dev/null +++ b/target/test-classes/saboteur_makes_pipe_slippery.feature @@ -0,0 +1,26 @@ +Feature: Saboteur standing on a pipe attempts to make it slippery + As a Saboteur, I want to be able to make pipes slippery, so that other players will not be able to stay on them. + + Scenario: A Saboteur with enough AP standing on a non-slippery pipe makes it slippery. + Given that a pipe is not slippery + And I am a Saboteur + And I am standing on the pipe + And I have enough AP + When I attempt to make the pipe slippery + Then the pipe should get slippery + + Scenario: A Saboteur standing on a slippery pipe attempts to make it slippery again. + Given that a pipe is slippery + And I am a Saboteur + And I am standing on the pipe + And I have enough AP + When I attempt to make the pipe slippery + Then nothing should happen, as the pipe is already slippery + + Scenario: A Saboteur without enough AP standing on a pipe attempts to make it slippery. + Given that a pipe is not slippery + And I am standing on the pipe + And I am a Saboteur + And I don't have enough AP + When I attempt to make the pipe slippery + Then the pipe shouldn't get slippery \ No newline at end of file