1919import static com .google .common .truth .Truth .assertThat ;
2020import static org .junit .Assert .assertThrows ;
2121import static org .junit .Assert .fail ;
22- import static org .junit .Assume .assumeTrue ;
22+ import static org .junit .Assume .assumeFalse ;
2323
2424import com .example .UnusedClass ;
2525import java .lang .reflect .InvocationTargetException ;
@@ -61,6 +61,11 @@ public void verifyJarExists() {
6161 }
6262 }
6363
64+ /** Returns whether the test is currently running for ProGuard, instead of R8 */
65+ private boolean isTestingProGuard () {
66+ return jarToTest .equals (PROGUARD_RESULT_PATH );
67+ }
68+
6469 @ FunctionalInterface
6570 interface TestAction {
6671 void run (Class <?> c ) throws Exception ;
@@ -216,6 +221,10 @@ public void test() throws Exception {
216221 "Read: Using Generic TypeToken" ,
217222 "{g={t=read-1}}" ,
218223 "===" ,
224+ "Read: Interface implementation" ,
225+ // TODO: Currently only works for ProGuard but not R8
226+ isTestingProGuard () ? "value" : "ClassCastException" ,
227+ "===" ,
219228 "" ));
220229 }
221230
@@ -226,7 +235,7 @@ public void testNoSerializedName_NoArgsConstructor() throws Exception {
226235 c -> {
227236 Method m = c .getMethod ("runTestNoArgsConstructor" );
228237
229- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
238+ if (isTestingProGuard ( )) {
230239 Object result = m .invoke (null );
231240 assertThat (result ).isEqualTo ("value" );
232241 } else {
@@ -251,7 +260,7 @@ public void testNoSerializedName_NoArgsConstructorNoJdkUnsafe() throws Exception
251260 c -> {
252261 Method m = c .getMethod ("runTestNoJdkUnsafe" );
253262
254- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
263+ if (isTestingProGuard ( )) {
255264 Object result = m .invoke (null );
256265 assertThat (result ).isEqualTo ("value" );
257266 } else {
@@ -278,7 +287,7 @@ public void testNoSerializedName_HasArgsConstructor() throws Exception {
278287 c -> {
279288 Method m = c .getMethod ("runTestHasArgsConstructor" );
280289
281- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
290+ if (isTestingProGuard ( )) {
282291 Object result = m .invoke (null );
283292 assertThat (result ).isEqualTo ("value" );
284293 } else {
@@ -300,7 +309,7 @@ public void testNoSerializedName_HasArgsConstructor() throws Exception {
300309 public void testUnusedClassRemoved () throws Exception {
301310 // For some reason this test only works for R8 but not for ProGuard; ProGuard keeps the unused
302311 // class
303- assumeTrue ( jarToTest . equals ( R8_RESULT_PATH ));
312+ assumeFalse ( isTestingProGuard ( ));
304313
305314 String className = UnusedClass .class .getName ();
306315 ClassNotFoundException e =
0 commit comments