This commit is contained in:
2025-09-18 01:02:03 +02:00
commit 8abb94290b
7 changed files with 295 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/UnitTests/JUnit4TestClass.java to edit this template
*/
package com.mycompany.bibliotheque;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class LivreTest {
private Livre livre;
@Before
public void setUp() {
// Création d'un livre avant chaque test
livre = new Livre("Java Basics", 20.0);
}
@Test
public void testGetTitre() {
assertEquals("pb titre","Java Basic", livre.getTitre());
}
@Test
public void testGetPrixHT() {
// Vérification du prix HT arrondi à 3 décimales
//assertEquals(20.0, livre.getPrixHT(), 0.001);
}
@Test
public void testIsEmprunte() {
// Par défaut, le livre n'est pas emprunté
assertFalse(livre.isEmprunte());
}
@Test
public void testSetEmprunte() {
livre.setEmprunte(true);
assertTrue(livre.isEmprunte());
livre.setEmprunte(false);
assertFalse(livre.isEmprunte());
}
@Test
public void testGetPrixTTC() {
// Calcul du prix TTC avec TVA 5.5% arrondi à 2 décimales
//assertEquals(21.1, livre.getPrixTTC(), 0.01);
}
}