junit4 – Android: Robolectric does not support API level 1-ThrowExceptions

Exception or error: This is my basic test class: @RunWith(RobolectricTestRunner.class) public class MainActivityTest { @Before public void setup() { //do whatever is necessary before every test } @Test public void testActivityFound() { Activity activity = Robolectric.buildActivity(MainActivity.class).create().get(); Assert.assertNotNull(activity); } } When I execute my test under Android Studio, with the Terminal window, I have this error: …

android – java.lang.Exception: Custom runner class AndroidJUnit4 should have a public constructor with signature AndroidJUnit4(Class testClass)-ThrowExceptions

Exception or error: gradle looks like: apply plugin: ‘com.android.application’ android { compileSdkVersion 25 buildToolsVersion “25.0.2” defaultConfig { applicationId “com.google.developer.taskmaker” minSdkVersion 19 targetSdkVersion 25 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } } configurations.all { resolutionStrategy { force ‘com.android.support:support-annotations:25.2.0’ } } dependencies { compile fileTree(dir: ‘libs’, …

java – Android Studio 2.1: error: package org.junit does not exist-ThrowExceptions

Exception or error: Update: Its a bug and it’s been reported, please star: https://code.google.com/p/android/issues/detail?id=209832&thanks=209832&ts=1463161330 I’m setting up unit testing on Android studio. I have read the documentation and set it up exactly as specified. I have my test folder set up as src/test/java I’ve made a random test class: import org.junit.Test; import static org.junit.Assert.*; import …

unit testing – Android Espresso : cannot resolve symbol AndroidJUnit4.class-ThrowExceptions

Exception or error: I’m trying to create Espresso UI test inside the new Android project but I faced with the following problem. If I tried to create a empty test class: import android.content.Intent; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; import android.test.ActivityInstrumentationTestCase2; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.withId; import …

Didn't find class "android.support.test.runner.AndroidJUnitRunner"-ThrowExceptions

Exception or error: I’m trying to use an instrumented test and I updated my project to AndroidX. But I get the following error while trying to run: 2018-10-09 14:22:29.468 13263-13263/xxx.yyy E/AndroidRuntime: FATAL EXCEPTION: main Process: xxx.yyy, PID: 13263 java.lang.RuntimeException: Unable to instantiate instrumentation ComponentInfo{xxx.yyy.test/android.support.test.runner.AndroidJUnitRunner}: java.lang.ClassNotFoundException: Didn’t find class “android.support.test.runner.AndroidJUnitRunner” on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]] at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5730) …