Skip to content

IUT-Blagnac/r5-a-08-qualdev-wailgana

 
 

Repository files navigation

R5.A.08 — Dépôt pour les TPs

Ce dépôt concerne les rendus de Wa-îl Gana.

TP1

Code de la page is_it_friday_yet.feature
---
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  |
---
TP 1   Test Successfull
Figure 1. Caprute d’écran de l’exécution avec succès des tests

TP2

Code de la page de order.java
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;

    }
}
capture2
Figure 2. Caprute d’écran de l’exécution avec succès des tests

TP3


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
---
Code de la page de Test compteur_click.py
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}"

Explication

  1. Étape @Given L’étape initialise les variables.

  2. Étapes @When Chaque étape simule une action utilisateur comme un clic simple ou un double clic en manipulant directement les variables.

  3. Étapes @Then Ces étapes vérifient si les compteurs correspondent aux valeurs attendues après les actions simulées.

Objectif

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.

TP3
Figure 3. Caprute d’écran de l’exécution avec succès des tests

TP4

Ayant eu des problèmes sur la machine de l’iut j’ai réalisé ce TP en binôme avec kilian boivert

Test du TP-1

[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] ------------------------------------------------------------------------

Test du TP-2

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] ------------------------------------------------------------------------

Test du TP-3

  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

Documentation améliorée avec cucumber

Je n’ai pas réussi à la faire fonctionner sur mon PC.

Documentation améliorée avec Cukedoctor

Projet du TP1
tp4 test cukedoctor TP1
Projet du TP2
tp4 test cukedoctor TP2
Projet du TP3

Le fichier que génère behave ne correspond à ce qu’attends Cukedoctor, je n’ai donc pas pu générer la documentation via Cukedoctor.

About

Template pour les TD de BDD

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 39.2%
  • Python 33.8%
  • Gherkin 27.0%