nenick / AndroidStudioAndRobolectric

Minimal Robolectric and Android Studio example
139 stars 29 forks source link

@Config and @RobolectricTestRunner not recognised #16

Closed krpot closed 9 years ago

krpot commented 9 years ago

I came from stackoverflow.com question.(http://stackoverflow.com/questions/29714750/android-studio-1-1-0-cannot-setup-robolectric). Thanks for your answer but I have cloned your project and tested your code, but Android Studio cannot recognise @Config and @RobolectricTestRunner annotations when I added @Config(emulateSdk = 18) @RunWith(value = RobolectricTestRunner.class) in the ApplicationTest class. Please let me know how I fix the issue.

import android.app.Application;
import android.test.ApplicationTestCase;

import org.junit.runner.RunWith;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
@Config(emulateSdk = 18)
@RunWith(value = RobolectricTestRunner.class)
public class ApplicationTest extends ApplicationTestCase<Application> {
    public ApplicationTest() {
        super(Application.class);
    }
}
nenick commented 9 years ago

Don't mix robolectric with instrumentation tests ;) Robolectric is designed to run on jvm instead of device or emulator. Did you read http://tools.android.com/tech-docs/unit-testing-support ?

krpot commented 9 years ago

nenick, it works now. Thanks.