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

De WikiEducator
Saltar a: navegación, buscar
Línea 45: Línea 45:
  
 
   $ nosetests
 
   $ nosetests
 +
 +
=== Configurar Eclipse / Aptana ===
 +
  Window --> Preferences --> PyDev  --> PyUnit --> Nose tests runner
 +
 +
Para ejecutar los tests:
 +
  Run As --> Python unit-test

Revisión de 21:41 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