google / google/truth

Make Subject#butWas protected

Open
#682 0 comments 0 reactions 1 assignee Claimed by @cpovirk View on GitHub
P3 type=addition
Dominant language
Java
Stars
2.8k
Forks
275
Avg merge
7m
Merged PRs (30d)
4

Description

@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.

```java
/*
* 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.
*/
```

https://github.com/google/truth/blob/b3fb67f1c5acf90bb53d9d85c1d96d67b283c7ba/core/src/main/java/com/google/common/truth/Subject.java#L1142

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.