Skip to content

Commit

Permalink
TP1 Done
Browse files Browse the repository at this point in the history
  • Loading branch information
Kylian committed Jan 7, 2025
1 parent fb0564c commit 246b92f
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 10 deletions.
29 changes: 19 additions & 10 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected][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 "<day>"
When I ask whether it's Friday yet
Then I should be told "<answer>"

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...
Binary file added ResultTestTP1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions hellocucumber/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>hellocucumber</groupId>
<artifactId>hellocucumber</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>7.14.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.2</version>
</plugin>
</plugins>
</build>
</project>
15 changes: 15 additions & 0 deletions hellocucumber/src/test/java/hellocucumber/RunCucumberTest.java
Original file line number Diff line number Diff line change
@@ -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 {
}
47 changes: 47 additions & 0 deletions hellocucumber/src/test/java/hellocucumber/StepDefinitions.java
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: An example

Scenario: The example
Given an example scenario
When all step definitions are implemented
Then the scenario passes
Original file line number Diff line number Diff line change
@@ -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 "<day>"
When I ask whether it's Friday yet
Then I should be told "<answer>"

Examples:
| day | answer |
| Friday | TGIF |
| Sunday | Nope |
| anything else! | Nope |

0 comments on commit 246b92f

Please sign in to comment.