2013_2014:lp:idse:gl:td:tests
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
2013_2014:lp:idse:gl:td:tests [2013/08/07 21:52] – [Créer une suite de tests JUnit] blay | 2013_2014:lp:idse:gl:td:tests [2014/10/10 05:54] (current) – [Tests unitaires avec Junit] blay | ||
---|---|---|---|
Line 5: | Line 5: | ||
Nous vous proposons ici d' | Nous vous proposons ici d' | ||
+ | |||
+ | |||
+ | Pour les étudiants qui pensent réaliser leur projet ou une partie de leur projet en php, | ||
+ | voici [[2014_2015: | ||
+ | |||
Line 56: | Line 61: | ||
http:// | http:// | ||
+ | |||
+ | ===== Tests paramétrés ===== | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | |||
+ | //Les tests paramétrés permettent d' | ||
+ | |||
+ | Voici ci-après un exemple de tests paramétrés. | ||
+ | Adaptez le à votre exemple. | ||
+ | |||
+ | <code java> | ||
+ | package math; | ||
+ | |||
+ | import static org.junit.Assert.*; | ||
+ | |||
+ | import java.util.Arrays; | ||
+ | import java.util.List; | ||
+ | |||
+ | import org.junit.After; | ||
+ | import org.junit.Before; | ||
+ | import org.junit.Test; | ||
+ | import org.junit.runner.RunWith; | ||
+ | import org.junit.runners.Parameterized; | ||
+ | import org.junit.runners.Parameterized.Parameters; | ||
+ | |||
+ | @RunWith(Parameterized.class) | ||
+ | public class ParametreTests { | ||
+ | |||
+ | Calculator op; | ||
+ | @Parameters | ||
+ | public static List< | ||
+ | return Arrays.asList(new Object[][] { | ||
+ | { 0, 0, 0 }, | ||
+ | { 1, 3, 4 }, | ||
+ | { 200, 800, 1000 } } ); | ||
+ | } | ||
+ | |||
+ | int first; | ||
+ | int second; | ||
+ | int result ; | ||
+ | | ||
+ | | ||
+ | first = premier; | ||
+ | this.second = second; | ||
+ | result = res; | ||
+ | } | ||
+ | | ||
+ | @Before | ||
+ | public void setUp() throws Exception { | ||
+ | op = new Calculator(); | ||
+ | } | ||
+ | |||
+ | @After | ||
+ | public void tearDown() throws Exception { | ||
+ | } | ||
+ | |||
+ | @Test | ||
+ | | ||
+ | System.out.println(first + "+ " + second +" | ||
+ | assertEquals(first, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
===== Exécuter les tests JUnit en dehors d' | ===== Exécuter les tests JUnit en dehors d' | ||
http:// | http:// | ||
- | ====== Tests d' | ||
- | http:// | ||
===== A vous !! ===== | ===== A vous !! ===== | ||
Line 70: | Line 140: | ||
* Continuez! | * Continuez! | ||
+ | <note warning> | ||
+ | |||
+ | ===== A la fin de cette séance ===== | ||
+ | |||
+ | <box round rgb(175, | ||
+ | * A quoi servent les tests? Quels types de tests existent-ils ? | ||
+ | * Avancé sur le développement du bus et j'ai créé les tests unitaires associés à mes codes; | ||
+ | * Utilisé le gestionnaire de version pour sauvegarder mes codes; | ||
+ | |||
+ | </ | ||
===== Références ===== | ===== Références ===== | ||
2013_2014/lp/idse/gl/td/tests.1375912337.txt.gz · Last modified: 2013/08/07 21:52 by blay