diff --git a/README.adoc b/README.adoc index 4af806c4..6be990db 100644 --- a/README.adoc +++ b/README.adoc @@ -2,21 +2,30 @@ :icons: font :MoSCoW: https://fr.wikipedia.org/wiki/M%C3%A9thode_MoSCoW[MoSCoW] -Ce dépôt concerne les rendus de mailto:A_changer@etu.univ-tlse2.fr[Jonh Doe]. +Ce dépôt concerne les rendus de https://github.com/Iamkylian[Kylian GACHET]. == TP1 -.Exemple de code -[source,java] +.Contenu du fichier ```is_it_friday_yet.feature``` +[source,text] --- -@Given("today is Sunday") -public void today_is_sunday() { - // Write code here that turns the phrase above into concrete actions - throw new io.cucumber.java.PendingException(); -} +Feature: Is it Friday yet? + Everybody wants to know when it's Friday + + Scenario Outline: Checking if it's Friday + Given today is "" + When I ask whether it's Friday yet + Then I should be told "" + + Examples: + | day | answer | + | Friday | TGIF | + | Sunday | Nope | + | anything else! | Nope | --- -.Exemple d'image insérée en asciidoc -image::artifacts-r303.svg[width=80%] +.Trace d'éxécution des tests du TP1 - Réussis +image::ResultTestTP1.png[Trace d'éxécution du test du TP1] + == TP2... diff --git a/ResultTestTP1.png b/ResultTestTP1.png new file mode 100644 index 00000000..339cc077 Binary files /dev/null and b/ResultTestTP1.png differ diff --git a/hellocucumber/pom.xml b/hellocucumber/pom.xml new file mode 100644 index 00000000..dfb7aafe --- /dev/null +++ b/hellocucumber/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + hellocucumber + hellocucumber + 1.0.0-SNAPSHOT + jar + + + UTF-8 + + + + + + io.cucumber + cucumber-bom + 7.14.1 + pom + import + + + org.junit + junit-bom + 5.10.1 + pom + import + + + + + + + io.cucumber + cucumber-java + test + + + + io.cucumber + cucumber-junit-platform-engine + test + + + + org.junit.platform + junit-platform-suite + test + + + + org.junit.jupiter + junit-jupiter + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + UTF-8 + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.2 + + + + diff --git a/hellocucumber/src/test/java/hellocucumber/RunCucumberTest.java b/hellocucumber/src/test/java/hellocucumber/RunCucumberTest.java new file mode 100644 index 00000000..9fcf7843 --- /dev/null +++ b/hellocucumber/src/test/java/hellocucumber/RunCucumberTest.java @@ -0,0 +1,15 @@ +package hellocucumber; + +import org.junit.platform.suite.api.ConfigurationParameter; +import org.junit.platform.suite.api.IncludeEngines; +import org.junit.platform.suite.api.SelectClasspathResource; +import org.junit.platform.suite.api.Suite; + +import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME; + +@Suite +@IncludeEngines("cucumber") +@SelectClasspathResource("hellocucumber") +@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") +public class RunCucumberTest { +} diff --git a/hellocucumber/src/test/java/hellocucumber/StepDefinitions.java b/hellocucumber/src/test/java/hellocucumber/StepDefinitions.java new file mode 100644 index 00000000..f26f9a34 --- /dev/null +++ b/hellocucumber/src/test/java/hellocucumber/StepDefinitions.java @@ -0,0 +1,47 @@ +package hellocucumber; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; + +public class StepDefinitions { + + private String today; + private String actualAnswer; + + @Given("today is {string}") + public void today_is(String day) { + today = day; + } + + @When("I ask whether it's Friday yet") + public void i_ask_whether_it_s_friday_yet() { + actualAnswer = IsItFriday.isItFriday(today); + } + + @Then("I should be told {string}") + public void i_should_be_told(String expectedAnswer) { + assertEquals(expectedAnswer, actualAnswer); + } + + @Given("an example scenario") + public void an_example_scenario() { + } + + @When("all step definitions are implemented") + public void all_step_definitions_are_implemented() { + } + + @Then("the scenario passes") + public void the_scenario_passes() { + } + +} + +class IsItFriday { + static String isItFriday(String today) { + return "Friday".equals(today) ? "TGIF" : "Nope"; + } +} \ No newline at end of file diff --git a/hellocucumber/src/test/resources/hellocucumber/example.feature b/hellocucumber/src/test/resources/hellocucumber/example.feature new file mode 100644 index 00000000..dc92c882 --- /dev/null +++ b/hellocucumber/src/test/resources/hellocucumber/example.feature @@ -0,0 +1,6 @@ +Feature: An example + + Scenario: The example + Given an example scenario + When all step definitions are implemented + Then the scenario passes diff --git a/hellocucumber/src/test/resources/hellocucumber/is_it_friday_yet.feature b/hellocucumber/src/test/resources/hellocucumber/is_it_friday_yet.feature new file mode 100644 index 00000000..ea5523af --- /dev/null +++ b/hellocucumber/src/test/resources/hellocucumber/is_it_friday_yet.feature @@ -0,0 +1,13 @@ +Feature: Is it Friday yet? + Everybody wants to know when it's Friday + + Scenario Outline: Checking if it's Friday + Given today is "" + When I ask whether it's Friday yet + Then I should be told "" + + Examples: + | day | answer | + | Friday | TGIF | + | Sunday | Nope | + | anything else! | Nope | \ No newline at end of file