google/truth

Make Subject#butWas protected

MariusVolkhart opened this issue · 0 comments

@cpovirk explains in comments for Subject.butWas() that it has a better implementation than what developers would typically do. We ran into this today, which implementing our own isEqualTo(). Given that protected access has been considered, I mostly want to indicate that there is interest in this.

  /*
   * TODO(cpovirk): Consider giving this protected access.
   *
   * It is likely better than what users would otherwise do -- `fact("but was", actual)`, which
   * ignores actualCustomStringRepresentation() (which is inaccessible outside the package).
   *
   * But I want to think more about this. In particular, if people use this to reimplement
   * isEqualTo(), I would be sad that they're missing out on its normal special handling. That's
   * probably not enough reason to avoid adding this, but we can hold it back for now.
   */