Introduce AssertJ for testing
- Lenguaje dominante
- Java
- Estrellas
- 3.1k
- Forks
- 1.6k
- Merge medio
- 3 d 12 h
- PR fusionados (30 d)
- 33
Descripción
### Describe the enhancement requested
AssertJ gives us readable, fluent assertions that make tests easier to write and failures easier to analyze. With JUnit's `assertEquals(expected, actual)` it's easy to mix up argument order, and you end up with confusing failure messages. AssertJ's `assertThat(actual).isEqualTo(expected)` reads naturally and always gets the order right. Additionally, it provides a lot of flexibility when asserting things.
Compound checks that need multiple JUnit assertions collapse into a single chain:
```
// JUnit
assertNotNull(list);
assertEquals(3, list.size());
assertTrue(list.contains("foo"));
```
```
// AssertJ
assertThat(list).hasSize(3).contains("foo");
```
When something fails, AssertJ tells you exactly what went wrong and makes debugging much easier, because the failure message usually contains enough details to understand the issue. For example, an assertion on a list would fail with `expected list to contain 'foo' but was ['bar', 'baz']`. JUnit assertions on the other hand would only contain `expected true but was false`.
It also covers cases where JUnit assertions are just clunky: exception messages, collection contents, map entries, string patterns, comparisons with custom comparators. All without needing Hamcrest matchers or custom helper methods.
I'm planning to add it as a project-wide test dependency so new tests can use it immediately. Existing tests don't need to be migrated, and we can move them over incrementally where it makes sense.
### Component(s)
_No response_
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
No se especifican archivos ni tests. Empieza por localizar la configuración de dependencias de test de todo el proyecto e inspecciona cómo se declaran las dependencias de test existentes; se considera terminado cuando AssertJ está disponible para los nuevos tests sin migrar los tests existentes y el build de tests del proyecto pasa correctamente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- testing
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 62/100