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

De WikiEducator
Saltar a: navegación, buscar
 
Línea 47: Línea 47:
  
 
=== Configurar Eclipse / Aptana ===
 
=== Configurar Eclipse / Aptana ===
 +
 +
* http://pydev.org/manual_adv_pyunit.html
 +
 
   Window --> Preferences --> PyDev  --> PyUnit --> Nose tests runner
 
   Window --> Preferences --> PyDev  --> PyUnit --> Nose tests runner
  
 
Para ejecutar los tests:
 
Para ejecutar los tests:
 
   Run As --> Python unit-test
 
   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