Skip to content

Commit 3f1f222

Browse files
committed
Migrate Truth subjects from the old fail(String, Object) to the new failWithActual(String, Object), tweaking verbs for the new grammar.
Before: fail("has foo", expected); After: failWithActual("expected to have foo", expected); ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244518456
1 parent 1093f73 commit 3f1f222

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/com/google/testing/compile/JavaFileObjectSubject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void isEqualTo(@Nullable Object other) {
7474
JavaFileObject otherFile = (JavaFileObject) other;
7575
try {
7676
if (!asByteSource(actual()).contentEquals(asByteSource(otherFile))) {
77-
fail("is equal to", other);
77+
failWithActual("expected to be equal to", other);
7878
}
7979
} catch (IOException e) {
8080
throw new RuntimeException(e);
@@ -85,7 +85,7 @@ public void isEqualTo(@Nullable Object other) {
8585
public void hasContents(ByteSource expected) {
8686
try {
8787
if (!asByteSource(actual()).contentEquals(expected)) {
88-
fail("has contents", expected);
88+
failWithActual("expected to have contents", expected);
8989
}
9090
} catch (IOException e) {
9191
throw new RuntimeException(e);

src/test/java/com/google/testing/compile/JavaSourcesSubjectFactoryTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ public void compilesWithoutError_throws() {
350350
.that(JavaFileObjects.forResource("HelloWorld-broken.java"))
351351
.compilesWithoutError();
352352
AssertionError expected = expectFailure.getFailure();
353-
assertThat(expected.getMessage()).startsWith("Compilation produced the following diagnostics:\n");
353+
assertThat(expected.getMessage()).startsWith("Compilation produced the following"
354+
+ " diagnostics:\n");
354355
assertThat(expected.getMessage()).contains("No files were generated.");
355356
}
356357

@@ -883,7 +884,7 @@ public void generatesFileNamed_failOnFileContents() {
883884
.withContents(ByteSource.wrap("Bogus".getBytes(UTF_8)));
884885
AssertionError expected = expectFailure.getFailure();
885886
assertThat(expected.getMessage()).contains("Foo");
886-
assertThat(expected.getMessage()).contains(" has contents ");
887+
assertThat(expected.getMessage()).contains(" have contents");
887888
}
888889

889890
@Test

0 commit comments

Comments
 (0)