1818import static androidx .test .ext .truth .os .ParcelableSubject .assertThat ;
1919import static androidx .test .ext .truth .os .ParcelableSubject .parcelables ;
2020import static com .google .common .truth .ExpectFailure .assertThat ;
21+ import static com .google .common .truth .ExpectFailure .expectFailureAbout ;
2122
2223import android .accounts .Account ;
2324import androidx .test .ext .junit .runners .AndroidJUnit4 ;
24- import com .google .common .truth .ExpectFailure ;
25- import org .junit .Rule ;
2625import org .junit .Test ;
2726import org .junit .runner .RunWith ;
2827
2928@ RunWith (AndroidJUnit4 .class )
3029public 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