Skip to content

Rename parameter to avoid name clashing #114

@joel-costigliola

Description

@joel-costigliola

If a class has an actual field/property, it clashes with the generated assertion actual parameter.

In this example, the actual parameter clashes with actual object under test in actual.getActual();

public S hasActual(boolean actual) {
  // check that actual Group we want to make assertions on is not null.
  isNotNull();

  // overrides the default error message with a more explicit one
  String assertjErrorMessage = "\nExpecting actual of:\n  <%s>\nto be:\n  <%s>\nbut was:\n  <%s>";

  // check
  boolean actualActual = actual.getActual();
  if (actualActual != actual) {
    failWithMessage(assertjErrorMessage, actual, actual, actualActual);
  }

  // return the current assertion for method chaining
  return myself;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions