Custom Truth subjects: Align name passed to Subject#check with reality
In order to print a nice failure message which matches the reality of the asserted objects, use the real name of the called method or property if it makes sense. When the assertion is on a derivative of a method or property or when the real name isn't helpful for a failure message (e.g. "ab" naming of common lines for diffs), keep using more descriptive pseudo-method names. Change-Id: I53fae276c57fe09fb43a58e77efd681b34b60eb7
This commit is contained in:
@@ -45,16 +45,16 @@ public class ChangeFileContentModificationSubject
|
||||
|
||||
public StringSubject filePath() {
|
||||
isNotNull();
|
||||
return check("filePath()").that(actual().getFilePath());
|
||||
return check("getFilePath()").that(actual().getFilePath());
|
||||
}
|
||||
|
||||
public StringSubject newContent() throws IOException {
|
||||
isNotNull();
|
||||
RawInput newContent = actual().getNewContent();
|
||||
check("newContent()").that(newContent).isNotNull();
|
||||
check("getNewContent()").that(newContent).isNotNull();
|
||||
String contentString =
|
||||
CharStreams.toString(
|
||||
new InputStreamReader(newContent.getInputStream(), StandardCharsets.UTF_8));
|
||||
return check("newContent()").that(contentString);
|
||||
return check("getNewContent()").that(contentString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user