Skip to content

Commit ea499ab

Browse files
cpovirkcopybara-androidxtest
authored andcommitted
Migrate off legacy, stateful expectFailure.
PiperOrigin-RevId: 879695139
1 parent 31f8a64 commit ea499ab

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

ext/truth/javatests/androidx/test/ext/truth/os/ParcelableSubjectTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@
1818
import static androidx.test.ext.truth.os.ParcelableSubject.assertThat;
1919
import static androidx.test.ext.truth.os.ParcelableSubject.parcelables;
2020
import static com.google.common.truth.ExpectFailure.assertThat;
21+
import static com.google.common.truth.ExpectFailure.expectFailureAbout;
2122

2223
import android.accounts.Account;
2324
import androidx.test.ext.junit.runners.AndroidJUnit4;
24-
import com.google.common.truth.ExpectFailure;
25-
import org.junit.Rule;
2625
import org.junit.Test;
2726
import org.junit.runner.RunWith;
2827

2928
@RunWith(AndroidJUnit4.class)
3029
public final class ParcelableSubjectTest {
3130

32-
@Rule public final ExpectFailure expectFailure = new ExpectFailure();
33-
3431
@Test
3532
public void marshallsEquallyTo() {
3633
Account account = new Account("name", "type");
@@ -42,9 +39,9 @@ public void marshallsEquallyTo() {
4239
public void marshallsEquallyTo_failure() {
4340
Account account = new Account("name", "type");
4441
Account other = new Account("different name", "type");
45-
expectFailure.whenTesting().about(parcelables()).that(account).marshallsEquallyTo(other);
46-
assertThat(expectFailure.getFailure())
47-
.factValue("expected to serialize like")
48-
.isEqualTo(other.toString());
42+
AssertionError failure =
43+
expectFailureAbout(
44+
parcelables(), whenTesting -> whenTesting.that(account).marshallsEquallyTo(other));
45+
assertThat(failure).factValue("expected to serialize like").isEqualTo(other.toString());
4946
}
5047
}

0 commit comments

Comments
 (0)