assertj / assertj/assertj-generator

Should assertions for properties of the superclass(es) be generated?

Aperta
#91 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
72
Fork
47
Merge medio
1g 16h
PR unite (30g)
2

Descrizione

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?

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo la configurazione del generatore in pom.xml e la documentazione referenziata nell’issue, quindi esamina come vengono incluse le assertions delle superclassi. Segui la gerarchia di esempio da SomeErrorException, passando per HttpResponseException, fino a Throwable e verifica la limitazione esistente di Assertions.assertThat(Throwable). Il lavoro è completato quando sarà stato deciso e documentato un approccio per generare assertions delle proprietà ereditate senza entrare in conflitto con le assertions esistenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
testing, tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.