|
1 | 1 | package com.google.inject.testing.throwingproviders; |
2 | 2 |
|
3 | | -import static com.google.common.truth.Truth.assertThat; |
| 3 | +import static com.google.common.truth.ExpectFailure.assertThat; |
4 | 4 | import static com.google.inject.testing.throwingproviders.CheckedProviderSubject.assertThat; |
5 | 5 |
|
6 | 6 | import com.google.common.truth.ExpectFailure; |
@@ -81,20 +81,29 @@ public void thrownException_threwUnexpected_expectFailure() { |
81 | 81 | Class<? extends Throwable> unexpected = UnsupportedOperationException.class; |
82 | 82 | CheckedProvider<String> provider = |
83 | 83 | CheckedProviders.throwing(StringCheckedProvider.class, unexpected); |
84 | | - String message = |
85 | | - String.format( |
86 | | - "value of : checkedProvider.get()'s exception\n" |
87 | | - + "expected instance of: %s\n" |
88 | | - + "but was instance of : %s\n" |
89 | | - + "with value : %s\n" |
90 | | - + "checkedProvider was : %s", |
91 | | - SummerException.class.getName(), |
92 | | - UnsupportedOperationException.class.getName(), |
93 | | - UnsupportedOperationException.class.getName(), |
94 | | - getThrowingProviderName(UnsupportedOperationException.class.getName())); |
95 | | - |
96 | 84 | expectWhenTesting().that(provider).thrownException().isInstanceOf(expected); |
97 | | - assertThat(expect.getFailure()).hasMessageThat().isEqualTo(message); |
| 85 | + AssertionError e = expect.getFailure(); |
| 86 | + assertThat(e) |
| 87 | + .factKeys() |
| 88 | + .containsExactly( |
| 89 | + "value of", |
| 90 | + "expected instance of", |
| 91 | + "but was instance of", |
| 92 | + "with value", |
| 93 | + "checkedProvider was"); |
| 94 | + assertThat(e).factValue("value of").isEqualTo("checkedProvider.get()'s exception"); |
| 95 | + assertThat(e) |
| 96 | + .factValue("expected instance of") |
| 97 | + .isAnyOf(SummerException.class.getName(), SummerException.class.getCanonicalName()); |
| 98 | + assertThat(e) |
| 99 | + .factValue("but was instance of") |
| 100 | + .isAnyOf( |
| 101 | + UnsupportedOperationException.class.getName(), |
| 102 | + UnsupportedOperationException.class.getSimpleName()); |
| 103 | + assertThat(e).factValue("with value").isEqualTo(UnsupportedOperationException.class.getName()); |
| 104 | + assertThat(e) |
| 105 | + .factValue("checkedProvider was") |
| 106 | + .isEqualTo(getThrowingProviderName(UnsupportedOperationException.class.getName())); |
98 | 107 | } |
99 | 108 |
|
100 | 109 | @Test |
|
0 commit comments