-
Notifications
You must be signed in to change notification settings - Fork 135
Revisión Pruebas ReusablePool #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Implementado el testGetInstance que prueba que el singleton creado por el método getInstance() funciona correctamente, no creando instancias nulas y mantiene la misma referencia tras hacer varias llamadas al método.
y formateado el archivo
…ida una nueva badge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request updates the project documentation and enhances the test suite for the reusable pool functionality.
- README.md now includes CI badges, editor credits, and links to test coverage reports.
- ReusablePoolTest.java is updated with improved tests for pool instance retrieval, acquisition, release, and client usage, and introduces an @AfterEach cleanup method.
Reviewed Changes
| File | Description |
|---|---|
| README.md | Added CI badges, editor credits, and coverage report links. |
| src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java | Improved tests and added cleanup for reusable pool functionality. |
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Co-authored-by: Copilot <[email protected]>
clopezno
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugiero mejorar la comprensión sobre conceptos básicos implementación de pruebas: para que sirve @AfterEach, añadir mensajes en los assert que ayuden a mejorar la comprensión en caso de ejecución fallida de la prueba, eliminar las referencias a System.out.println
|
|
||
| /* | ||
| * Funcionalidad: Se ejecuta después de cada prueba e intenta adquirir todas las instancias reutilizables | ||
| * del pool y luego libera nuevas instancias para restablecer el estado del pool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este comentario no es necesario.
| } | ||
| } catch (NotFreeInstanceException e) { | ||
| try { | ||
| System.out.println("Med" + pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No se incluyen System.out.println en los test
| @AfterEach | ||
| public void despues() { | ||
| ReusablePool pool = ReusablePool.getInstance(); | ||
| System.out.println("Antes" + pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No se incluyen System.out.println en los test
| try { | ||
| while (true) { | ||
| pool.acquireReusable(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
El objetivo de @AfterEach es liberar todo lo que se haya reservado en @beforeeach. Esta porción de código no procede.
| assertNotNull(pool1); | ||
| assertNotNull(pool2); | ||
| assertSame(pool1, pool2); | ||
| assertEquals(pool1, pool2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Añadir mensajes descriptivos del caso de prueba en los assert ayuda a mejorar la comprensión en caso de producirse el error detectado por la prueba. Este comentario de revisión intenta mejorar la facilidad de mantenimiento.
| public void testAcquireReusable() { | ||
|
|
||
| ReusablePool pool = ReusablePool.getInstance(); | ||
| System.out.println(pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No se añade un system.out.println a una caso de prueba
| * | ||
| */ | ||
| public class ReusablePoolTest { | ||
| private static final int num = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dos comentarios
- Por convención de nombres en Java las constantes se escriben en mayúsculas
- num no describe con precisión su objetivo, aconsejo renombrar POOL_TAM_MAX
| public void testClient() { | ||
| assertNotNull(new Client()); | ||
| assertDoesNotThrow(() -> Client.main(null)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Esta prueba esta fuera del contexto de prueba Reusablepool se debería eliminar de este fichero. Además, Reusable es una implementación de compromiso que no debería ser probada. Entiendo que se ha añadido para conseguir el 100% de cobertura del sistema. Si se quiere eliminar el seguimiento de su cobertura se puede indicar en el fichero de configuración de .codecov.yml añadiendo
ignore:
- "src/main/java/ubu/gii/dass/c01/Client.java"
- "src/main/java/ubu/gii/dass/c01/Reusable.java"
| System.out.println(pool); | ||
| try { | ||
| for (int i = 0; i < ReusablePoolTest.num; i++) { | ||
| pool.acquireReusable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se necesita probar que pool.acquireReusable() retorna un objeto de Reusable.
Reusable reusable = pool.acquireReusable();
assertNotNull(reusable,"El objeto reusable adquirido no debería ser nulo");
assertTrue(reusable instanceof Reusable, "El objeto adquirido debe ser una instancia de Reusable");
No description provided.