assertj / assertj/assertj-generator

The generator is a little too greedy with Iterable of Path and make tests fails

Offen
#115 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
72
Forks
47
Ø Merge
1 T. 16 Std.
Gemergte PRs (30 T.)
2

Beschreibung

With 2.1.0 version, the generator is too greedy when encountering a class implementing an `java.lang.Iterable`. It should ignore it unless the type extends `java.util.Collection` (where that make sense) or explicitly a `java.lang.Iterable` (where it is harder to tell it makes sense).

Sample classes: [assertj-foo.zip](https://github.com/joel-costigliola/assertj-assertions-generator/files/1377297/assertj-foo.zip)

The test (`FooTest`) will fail because the usage of hasPath is NOT the same than using an iterable: we want to test an equals rather than a collection predicate. Here the exception: _java.lang.AssertionError: Expecting: to contain: <[foobar\a]>but could not find: <[foobar\a]>_

A working alternative is to convert the Path into a List extracting the Iterable content, but that is wrong by all means:
- first, the default semantic is not good (the default = search for subsequence in any order)
- second, as an user, I want to test the path using `equals` (and that is what the generator produce if I have a class not implementing `java.lang.Iterable`):

```
final List paths = new ArrayList<>();
test.forEach(paths::add); // says ["foobar", "A"]
assertThat(foo).hasPath(paths);
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start by unpacking the linked assertj-foo.zip sample and running FooTest to reproduce the failing hasPath assertion. Trace how the generator handles types implementing java.lang.Iterable, including the distinction from java.util.Collection. Done means Path-like Iterable types use equality semantics while collection types retain collection predicates, with the test passing.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.