assertj / assertj/assertj-generator
Should assertions for properties of the superclass(es) be generated?
- Lenguaje dominante
- Java
- Estrellas
- 72
- Forks
- 47
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 2
Descripción
Consider this class:
```
import org.apache.http.client.HttpResponseException;
public class SomeErrorException extends HttpResponseException {
private SomeError error;
public SomeErrorException(int statusCode, String reason, SomeError error) {
super(statusCode, reason);
this.error = error;
}
public SomeError getError() {
return error;
}
}
```
It would be nice to be able to test `SomeErrorException` objects like this:
```
assertThat(exception).hasStatusCode(500)
.hasMessage("Internal Server Error")
.hasError(error)
```
However, `hasStatusCode` and `hasMessage` are not generated because they are defined in superclasses. If I include `HttpResponseException` in the generator configuration (in `pom.xml`), the `hasStatusCode` appear, but of course `hasMessage` is only present if I also include the whole hierarchy (four classes!) up to `Throwable`. Also, `org.assertj.core.api.Assertions.assertThat(Throwable)` already exists, so I cannot make my assertions a subclass (but problem with this idea are already discussed in the documentation).
Does it make sense to make it easier to include assertions for properties of superclasses?
Guía de contribución
Línea de trabajo
Comienza leyendo la configuración del generador en pom.xml y la documentación referenciada en la issue; después, inspecciona cómo se incluyen las assertions de las superclases. Sigue la jerarquía de ejemplo desde SomeErrorException, pasando por HttpResponseException, hasta Throwable, y revisa la limitación existente de Assertions.assertThat(Throwable). Se considera completado cuando exista un enfoque decidido y documentado para generar assertions de propiedades heredadas sin entrar en conflicto con las assertions existentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- testing, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100