Projet

Général

Profil

TestsCodeBonnesPratiques » Historique » Version 2

Daniel Dehennin, 13/11/2014 14:35

1 2 Daniel Dehennin
*DRAFT*
2 2 Daniel Dehennin
3 1 Gwenael Remond
h1. TestsCodeBonnesPratiques
4 1 Gwenael Remond
5 1 Gwenael Remond
* créer un dossier de tests dans le projet (typiquement <code>tests</code>)
6 1 Gwenael Remond
* l'écriture des tests se fait avec l'outil <code>py.test</code> (http://pytest.org/latest/)
7 1 Gwenael Remond
* **attention** : ces tests seront pris en compte lors de la compilation d'un paquet (en d'autres termes, si les tests ne passent pas, le paquet ne sera pas compilé) 
8 1 Gwenael Remond
* pour dissocier la notion de test unitaire de la notion de test fonctionnel, il importe de "tagger" le test avec le mot clef correspondant, à savoir : 
9 1 Gwenael Remond
10 1 Gwenael Remond
pour un test unitaire : 
11 1 Gwenael Remond
<pre>
12 1 Gwenael Remond
py.test.mark.unitary 
13 1 Gwenael Remond
</pre>
14 1 Gwenael Remond
15 1 Gwenael Remond
pour un test fonctionnel : 
16 1 Gwenael Remond
<pre>
17 1 Gwenael Remond
py.test.mark.functional
18 1 Gwenael Remond
</pre>
19 1 Gwenael Remond
20 1 Gwenael Remond
à utiliser en tant que décorateur, par exemple : 
21 1 Gwenael Remond
22 1 Gwenael Remond
<pre>
23 1 Gwenael Remond
@py.test.mark.unitary 
24 1 Gwenael Remond
def mon_test():
25 1 Gwenael Remond
    assert ma_fonction(2) == 3
26 1 Gwenael Remond
</pre>