From 07a187dc5ac1eabf5a838bedc8365483e5f5601e Mon Sep 17 00:00:00 2001 From: Simon Catanese Date: Fri, 28 Jun 2024 01:09:00 +0200 Subject: [PATCH] BDD --- .../iut_fbleau/but3/dev6_2/CucumberTest.java | 2 + .../dev6_2/steps/EightQueensSolverSteps.java | 99 ++++++++++++++++--- .../resources/features/placeAQueen.feature | 30 +++--- .../features/removeAQueen copy.feature | 15 +++ .../resources/features/solveProblem.feature | 14 +++ 5 files changed, 132 insertions(+), 28 deletions(-) create mode 100644 src/test/resources/features/removeAQueen copy.feature create mode 100644 src/test/resources/features/solveProblem.feature diff --git a/src/test/java/fr/iut_fbleau/but3/dev6_2/CucumberTest.java b/src/test/java/fr/iut_fbleau/but3/dev6_2/CucumberTest.java index 74139e2..dc928c8 100644 --- a/src/test/java/fr/iut_fbleau/but3/dev6_2/CucumberTest.java +++ b/src/test/java/fr/iut_fbleau/but3/dev6_2/CucumberTest.java @@ -12,4 +12,6 @@ import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; @SelectClasspathResource("features") @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "fr.iut_fbleau.but3.dev6_2.steps") public class CucumberTest { + + } diff --git a/src/test/java/fr/iut_fbleau/but3/dev6_2/steps/EightQueensSolverSteps.java b/src/test/java/fr/iut_fbleau/but3/dev6_2/steps/EightQueensSolverSteps.java index a308b7d..31e1e5b 100644 --- a/src/test/java/fr/iut_fbleau/but3/dev6_2/steps/EightQueensSolverSteps.java +++ b/src/test/java/fr/iut_fbleau/but3/dev6_2/steps/EightQueensSolverSteps.java @@ -1,27 +1,104 @@ package fr.iut_fbleau.but3.dev6_2.steps; -import fr.iut_fbleau.but3.dev6_2.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import fr.iut_fbleau.but3.dev6_2.Chessboard; +import fr.iut_fbleau.but3.dev6_2.EightQueensSolver; +import fr.iut_fbleau.but3.dev6_2.Position; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import static org.junit.jupiter.api.Assertions.assertEquals; - public class EightQueensSolverSteps { - private EightQueensSolver eightQueensSolver; + private EightQueensSolver solver; - @Given("un echiquier") - public void unEchiquier() { - this.eightQueensSolver = new EightQueensSolver(); + private Position lastRemovedQueen; + + @Given("un echiquier vide") + public void unEchiquierVide() { + this.solver = new EightQueensSolver(); + this.solver.setChessboard(new Chessboard()); + } + + @Given("un echiquier avec {int} reines valides") + public void unEchiquierAvecXReinesValides(int nbReines) { + + Position[] positions = {new Position(3, 0), new Position(1, 1), new Position(6, 2), new Position(2, 3), new Position(5, 4), new Position(7, 5), new Position(4, 6), new Position(0, 7)}; + + this.solver = new EightQueensSolver(); + this.solver.setChessboard(new Chessboard()); + nbReines = (nbReines > Chessboard.SIZE) + ? Chessboard.SIZE + : nbReines; + for(int i=0 ; i