From 3f1f22201d9cd0a2f1d5b3255e5787645f098d5c Mon Sep 17 00:00:00 2001 From: cpovirk Date: Sat, 20 Apr 2019 14:51:09 -0700 Subject: [PATCH] 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 --- .../com/google/testing/compile/JavaFileObjectSubject.java | 4 ++-- .../testing/compile/JavaSourcesSubjectFactoryTest.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/google/testing/compile/JavaFileObjectSubject.java b/src/main/java/com/google/testing/compile/JavaFileObjectSubject.java index 677b937c..0a136984 100644 --- a/src/main/java/com/google/testing/compile/JavaFileObjectSubject.java +++ b/src/main/java/com/google/testing/compile/JavaFileObjectSubject.java @@ -74,7 +74,7 @@ public void isEqualTo(@Nullable Object other) { JavaFileObject otherFile = (JavaFileObject) other; try { if (!asByteSource(actual()).contentEquals(asByteSource(otherFile))) { - fail("is equal to", other); + failWithActual("expected to be equal to", other); } } catch (IOException e) { throw new RuntimeException(e); @@ -85,7 +85,7 @@ public void isEqualTo(@Nullable Object other) { public void hasContents(ByteSource expected) { try { if (!asByteSource(actual()).contentEquals(expected)) { - fail("has contents", expected); + failWithActual("expected to have contents", expected); } } catch (IOException e) { throw new RuntimeException(e); diff --git a/src/test/java/com/google/testing/compile/JavaSourcesSubjectFactoryTest.java b/src/test/java/com/google/testing/compile/JavaSourcesSubjectFactoryTest.java index 29e9d16a..ec202236 100644 --- a/src/test/java/com/google/testing/compile/JavaSourcesSubjectFactoryTest.java +++ b/src/test/java/com/google/testing/compile/JavaSourcesSubjectFactoryTest.java @@ -350,7 +350,8 @@ public void compilesWithoutError_throws() { .that(JavaFileObjects.forResource("HelloWorld-broken.java")) .compilesWithoutError(); AssertionError expected = expectFailure.getFailure(); - assertThat(expected.getMessage()).startsWith("Compilation produced the following diagnostics:\n"); + assertThat(expected.getMessage()).startsWith("Compilation produced the following" + + " diagnostics:\n"); assertThat(expected.getMessage()).contains("No files were generated."); } @@ -883,7 +884,7 @@ public void generatesFileNamed_failOnFileContents() { .withContents(ByteSource.wrap("Bogus".getBytes(UTF_8))); AssertionError expected = expectFailure.getFailure(); assertThat(expected.getMessage()).contains("Foo"); - assertThat(expected.getMessage()).contains(" has contents "); + assertThat(expected.getMessage()).contains(" have contents"); } @Test