Ce dépôt concerne les rendus de Wa-îl Gana.
---
Feature: Is it Friday yet?
Everybody wants to know when it's Friday
Scenario Outline: Tests 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 | ---
package dojo;
import java.util.ArrayList;
import java.util.List;
class Order {
String owner;
List<String> cocktails =new ArrayList<>();
String target;
public void declareOwner(String owner) {
this.owner = owner;
}
public void declareTarget(String target) {
this.target = target;
}
public List<String> getCocktails() {
return cocktails;
}
}
Feature: Click Counter Application
Scenario: User clicks the "Click me!" button once Given I have opened the Click Counter application When I click the "Click me!" button Then the click count should be 1 And the double click count should be 0
Scenario: User clicks the "Click me!" button multiple times Given I have opened the Click Counter application When I click the "Click me!" button 3 times Then the click count should be 3 And the double click count should be 0
Scenario: User clicks the "Double Click here!" button once Given I have opened the Click Counter application When I click the "Double Click here!" button Then the click count should be 2 And the double click count should be 1
Scenario: User clicks both buttons once Given I have opened the Click Counter application When I click the "Click me!" button And I click the "Double Click here!" button Then the click count should be 3 And the double click count should be 1
Scenario: User clicks the "Double Click here!" button twice Given I have opened the Click Counter application When I click the "Double Click here!" button twice Then the click count should be 4 And the double click count should be ---
from behave import given, when, then
import tkinter as tk
from maincompteur import ClickCounterApp
@given('I have opened the Click Counter application')
def step_given_open_application(context):
context.root = tk.Tk()
context.app = ClickCounterApp(context.root)
@when('I click the "Click me!" button')
def step_when_click_button(context):
context.app.increment_count()
@when('I click the "Click me!" button {times:d} times')
def step_when_click_button_multiple_times(context, times):
for _ in range(times):
context.app.increment_count()
@when('I click the "Double Click here!" button')
def step_when_double_click_button(context):
context.app.add_double_clicks()
@when('I click the "Double Click here!" button twice')
def step_when_double_click_button_multiple_times(context):
for _ in range(2):
context.app.add_double_clicks()
@when('I click the "Click me!" button and I click the "Double Click here!" button')
def step_when_click_both_buttons(context):
context.app.increment_count()
context.app.add_double_clicks()
@then('the click count should be {expected_count:d}')
def step_then_check_click_count(context, expected_count):
assert context.app.click_count == expected_count, f"Expected {expected_count}, but got {context.app.click_count}"
@then('the double click count should be {expected_count:d}')
def step_then_check_double_click_count(context, expected_count):
assert context.app.double_click_count == expected_count, f"Expected {expected_count}, but got {context.app.double_click_count}"
-
Étape @Given L’étape initialise les variables.
-
Étapes @When Chaque étape simule une action utilisateur comme un clic simple ou un double clic en manipulant directement les variables.
-
Étapes @Then Ces étapes vérifient si les compteurs correspondent aux valeurs attendues après les actions simulées.
L’objectif était de tester une application simple, créée lors de la première année, pour vérifier que toutes ses fonctionnalités fonctionnent correctement. Étant donné la simplicité de l’application (gestion de clics et double clics), il n’y avait pas un grand nombre de tests nécessaires. L’idée était d’appliquer des tests basiques pour garantir que la logique derrière les compteurs fonctionne comme prévu.
Ayant eu des problèmes sur la machine de l’iut j’ai réalisé ce TP en binôme avec kilian boivert
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running hellocucumber.RunCucumberTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.427 s -- in hellocucumber.RunCucumberTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.047 s
[INFO] Finished at: 2025-01-13T09:09:21+01:00
[INFO] ------------------------------------------------------------------------
2 Scenarios (2 passed)
6 Steps (6 passed)
0m0,017s
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.305 sec
Results :
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.391 s
[INFO] Finished at: 2025-01-13T09:10:58+01:00
[INFO] ------------------------------------------------------------------------
Scenario Outline: RÚinitialiser le compteur -- @1.1 # features/compteur.feature:36
Given l'application est lancÚe # features/steps/compteur_steps.py:5
When je clique sur "Augmenter" # features/steps/compteur_steps.py:10
And je clique sur "RÚinitialiser" # features/steps/compteur_steps.py:10
Then le compteur doit afficher "Compteur : 0" # features/steps/compteur_steps.py:32
Scenario Outline: RÚinitialiser le compteur -- @1.2 # features/compteur.feature:37
Given l'application est lancÚe # features/steps/compteur_steps.py:5
When je clique sur "RÚduire" # features/steps/compteur_steps.py:10
And je clique sur "RÚinitialiser" # features/steps/compteur_steps.py:10
Then le compteur doit afficher "Compteur : 0" # features/steps/compteur_steps.py:32
1 feature passed, 0 failed, 0 skipped
6 scenarios passed, 0 failed, 0 skipped
28 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.695s