This commit is contained in:
52
src/test/java/com/mycompany/bibliotheque/LivreTest.java
Normal file
52
src/test/java/com/mycompany/bibliotheque/LivreTest.java
Normal 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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dthev
|
||||
*/
|
||||
public class UtilisateurTest {
|
||||
|
||||
public UtilisateurTest() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getNom method, of class Utilisateur.
|
||||
*/
|
||||
@Test
|
||||
public void testGetNom() {
|
||||
System.out.println("getNom");
|
||||
Utilisateur instance = null;
|
||||
String expResult = "";
|
||||
String result = instance.getNom();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getEmprunts method, of class Utilisateur.
|
||||
*/
|
||||
@Test
|
||||
public void testGetEmprunts() {
|
||||
System.out.println("getEmprunts");
|
||||
Utilisateur instance = null;
|
||||
List<Livre> expResult = null;
|
||||
List<Livre> result = instance.getEmprunts();
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of emprunterLivre method, of class Utilisateur.
|
||||
*/
|
||||
@Test
|
||||
public void testEmprunterLivre() {
|
||||
System.out.println("emprunterLivre");
|
||||
Livre livre = null;
|
||||
Utilisateur instance = null;
|
||||
boolean expResult = false;
|
||||
boolean result = instance.emprunterLivre(livre);
|
||||
assertEquals(expResult, result);
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user