I am trying unit test in my android app and it is a simple test tutorial what i am doing.
import static org.junit.Assert.*; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; @RunWith(RobolectricTestRunner.class) public class ServerListManagerTest extends AndroidTestCase{ @Test public void testTrueIsTrue() throws Exception { assertEquals(true, true); } }
The directory is as follows: src\main\androidTest\java\some packages\ServerListManagerTest.java
I tried changing the directory of this as well as creating a configuration. but android studio still does not recognize my unit test, although the assembly was successful.
This is my build.gradle in the application,
apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.kaist.se.pmpapp" minSdkVersion 16 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { java.srcDirs = ['src/main/java', 'src/androidTest/java'] } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' androidTestCompile 'org.robolectric:robolectric:2.4' androidTestCompile 'junit:junit:4.12' androidTestCompile group: 'junit', name: 'junit', version: '4.12' }
What is wrong in my code ????
android-studio android-gradle unit-testing junit gradle
W.Cointreau
source share