Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#115 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

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.

Written by the indexing model from the issue text.

Description

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

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: <foobar\a>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<Path> paths = new ArrayList<>();
test.forEach(paths::add); // says ["foobar", "A"]
assertThat(foo).hasPath(paths);
Dominant language
Java
Stars
72
Forks
47
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from assertj/assertj-generator

All issues in assertj/assertj-generator

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.