Difference between
version 19
and
version 18:
At line 205 changed 1 line. |
The code you see above is what we need for a basic JUnit test that initializes and destroys our PersonDao. The "ctx" object is a reference to Spring's ApplicationContext, which is initialized in a static block of the [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html] class. |
El código anterior es lo que Ud. necesita para realizar una prueba unitaria básica que inicialize y destruya nuestro PersonDao. El objeto "ctx" es una referencia al objeto Application Context de Spring, el cual es inicializado en un bloque estático de la clase [BaseDaoTestCase's|http://raibledesigns.com/downloads/appfuse/api/org/appfuse/dao/BaseDaoTestCase.java.html] . |
At line 207 changed 1 line. |
Now we need to actually test that the CRUD (create, retrieve, update, delete) methods work in our DAO. To do this we created methods that begin with "test" (all lower case). As long as these methods are public, have a void return type and take no arguments, they will be called by our <junit> task in our Ant build.xml file. Here's some simple tests for testing CRUD. An important thing to remember is that each method (also known as a test), should be autonomous. Add the following methods to your PersonDaoTest.java file: |
Ahora necesitamos probar que las operaciones CRUD (create, retrieve, update, delete) methods funcionan en nuestro DAO. Para ello, crearemos metodos que empiecen con el vocablo "test" (en minúsculas). Estos métodos al ser públicos,retornan void y no aceptan parámetros de entrada, serán ejecutados por la tarea <junit> que se encuentra en el fichero build.xml de Ant . |
At line 209 added 3 lines. |
Aca le mostramos algunas pruebas sencillas para probar las operaciones CRUD. Lo importante a recordad es que cada método debe ser autónomo. Anada los siguientes metodos a la clase |
PersonDaoTest.java: |
|
At line 273 changed 1 line. |
;:%%(color: blue)''This way, you can eliminate the "create new" functionality in the testGetPerson method. If you'd rather add this record directly into the database (via SQL or a GUI), you can rebuild your sample-data.xml file using "ant db-export" and then "cp db-export.xml metadata/sql/sample-data.xml".''%% |
;:%%(color: blue)''De esta manera,puedes eliminar la funcionalidad "create new" en el método testGetPerson. Si prefiere anadir este record directamente a la base de datos , (via SQL o una intefaz GUI), you can rebuild your sample-data.xml file using "ant db-export" and then "cp db-export.xml metadata/sql/sample-data.xml".''%% |
Back to CreateDAO_es,
or to the Page History.
|