Diferencia entre revisiones de «Usuario:Lmorillas/modulo programacion/python/introduccion a los tests»

De WikiEducator
Saltar a: navegación, buscar
(Página creada con '{{MiTitulo| Introducción a los tests en Python}} {{Lectura| TOCdepth=3| * http://en.wikipedia.org/wiki/Portal:Software_Testing * http://readthedocs.org/docs/nose/en/latest/ * …')
 
 
(2 revisiones intermedias por el mismo usuario no mostrado)
Línea 32: Línea 32:
 
    
 
    
 
   OK
 
   OK
 +
 +
===Escribir tests===
 +
Mira estos [http://learnpythonthehardway.org/book/ex47.html ejemplos]
 +
 +
<source lang="python">
 +
def test_a():
 +
    assert ...
 +
 +
</source>
 +
 +
Para comprobar:
 +
 +
  $ nosetests
 +
 +
=== Configurar Eclipse / Aptana ===
 +
 +
* http://pydev.org/manual_adv_pyunit.html
 +
 +
  Window --> Preferences --> PyDev  --> PyUnit --> Nose tests runner
 +
 +
Para ejecutar los tests:
 +
  Run As --> Python unit-test

Última revisión de 21:42 15 feb 2012


Lectura



Tipos de tests

  • Tests unitarios
  • Tests funcionales
  • Tests de usuario

Instalar nose

Puedes usar pip o easy_install:

easy_install nose

o

pip install nose

O instalar desde el código fuente:

python setup.py install

Escribe los tests en el proyecto y:Now you can run tests for your project:

 cd path/del/proyecto
 nosetests

Verás algo así:

 ..................................
 ----------------------------------------------------------------------
 Ran 34 tests in 1.440s
 
 OK

Escribir tests

Mira estos ejemplos

def test_a():
    assert ...

Para comprobar:

 $ nosetests

Configurar Eclipse / Aptana

 Window --> Preferences --> PyDev  --> PyUnit --> Nose tests runner

Para ejecutar los tests:

 Run As --> Python unit-test