assertj-assertions-generator icon indicating copy to clipboard operation
assertj-assertions-generator copied to clipboard

Rename parameter to avoid name clashing

Open joel-costigliola opened this issue 8 years ago • 1 comments

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;
}

joel-costigliola avatar Sep 30 '17 04:09 joel-costigliola

Hi,

Is this issue still relevant?

The test for FieldPropertyClash seems cover the case; the generated method parameter seems to be expectedActual.

ghostd avatar Sep 22 '19 19:09 ghostd