We are trying to use the Robolectric testing platform in Android Studio to test the Facebook API. The Facebook login button works so that the Facebook API works. However, the following test fails:
package com.airportapp.test.Models;
import android.app.Activity;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.Robolectric;
import com.airportapp.test.MyRobolectricTestRunner;
import com.airportapp.LoginActivity;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(MyRobolectricTestRunner.class)
public class LoginActivityTest {
@Before
public void setup() {
}
@Test
public void testActivityFound() {
Activity activity = Robolectric.buildActivity(LoginActivity.class).create().get();
Assert.assertNotNull(activity);
}
}
And the error is that Android Studio could not find the android.support file when we run the tests. You can see the error here:
Another error that appears: android.view.InflateException: XML file app / src / main / res / layout / activity_login.xml line # -1 (sorry, not yet implemented): error inflating class com.facebook.widget.LoginButton
So, Android Studio doesnโt like the facebook login button :( But it works ... We think we need to import something, but we donโt know where to put it.