assertj / assertj/assertj-generator

Feature: Generate IterableAsserts for all generated Asserts

Abierto
#219 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
72
Forks
47
Merge medio
1 d 16 h
PR fusionados (30 d)
2

Descripción

We would like to write something like this:

```java
List result;
assertThat(result).singleElement().hasName("Fool")
```

Now, we can generate `FooAssert` with the generator, but the `ListAssert` we get out of `assertThat` in this case does, of course, not known about the generated assertion; we get a regular `ObjectAssert`.

We can work around this by creating something like this here:

```java
public class FooIterableAssert
extends AbstractIterableAssert, Foo, FooIterableAssert> {

protected FooIterableAssert(Iterable foos, Class selfType) {
super(foos, selfType);
}

@Override
protected FooAssert toAssert(Foo value, String description) {
return new FooAssert(value);
}

@Override
protected FooIterableAssert newAbstractIterableAssert(Iterable iterable) {
return new FooIterableAssert(iterable, FooIterableAssert.class);
}

public static FooIterableAssert assertThat(List foos) {
return new FooIterableAssert(foos, FooIterableAssert.class);
}
}
```

This has the feel of "should be a template" and "surely not only we want this", so I'm raising this issue. :)
I'm also not sure whether one would have/want to fiddle with the entrypoint methods in support of this.

PS: I was considering to use Lombok's `@ExtensionMethod` on `ListAssert` to add something like `FooAssert singleFoo()` to it. Unfortunately, it does not seem possible to get the actual _value_ back from an Assert, so I was stuck there.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza siguiendo el generador de assertions que crea FooAssert y, a continuación, inspecciona cómo se generan ListAssert y los puntos de entrada assertThat. Compara la forma solicitada de FooIterableAssert con la salida generada actualmente y decide cómo deberían exponerse las assertions iterables generadas. Se considera terminado cuando las assertions generadas admiten el uso solicitado de singleElement().hasName("Fool") sin clases wrapper manuales.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
java
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.