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

Using generateAssertionsInPackage in Maven results in compilation issues

Open
#135 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the issue with the Maven generate-assertions goal and the generateAssertionsInPackage setting using the Holder and MyCustomClass example. Trace how imports are produced for generated assertion classes, then verify that the generated AbstractHolderAssert compiles when the referenced type is in another package.

Written by the indexing model from the issue text.

Description

Summary

Some classes for which I generate assertion classes contain methods with parameter types that are in the same package. If I then use <generateAssertionsInPackage> to generate the assertion classes in a different package, they miss the required imports for these types.

Example
public class Holder {
   private Collection<? extends MyCustomClass> values;
}
<plugin>
    <groupId>org.assertj</groupId>
    <artifactId>assertj-assertions-generator-maven-plugin</artifactId>
    <version>2.1.0</version>
    <executions>
        <execution>
            <goals>
                <goal>generate-assertions</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <generateAssertionsInPackage>assertj.generated.assertions</generateAssertionsInPackage>
    </configuration>
</plugin>

Results in the following assertion class:

public class HolderAssert extends AbstractHolderAssert<HolderAssert, Holder> {
   (..)
}
import org.assertj.core.api.AbstractObjectAssert;
import org.assertj.core.internal.Iterables;
import org.assertj.core.util.Objects;

public abstract class AbstractHolderAssert<S extends AbstractHolderAssert<S, A>, A extends Holder> extends AbstractObjectAssert<S, A> {

  (..)

  // class MyCustomClass not imported == compilation error -->
  public S hasValues(MyCustomClass... values) {
    (..)
  }
}
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.