I have a test project in IntelliJ (using the Android Studio plugin), and I'm trying to set up unit tests as described here .
When running the junit test, the project cannot find my sources in src> main> java. Next test
package io.adaptiv.plzwrk.lib; import junit.framework.TestCase; import org.junit.Test; public class AdaptivTest extends TestCase { @Test public void testDoStuff() throws Exception { assertEquals(42, Adaptiv.doStuff()); } }
gives an error
error: cannot find symbol assertEquals(42, Adaptiv.doStuff()); ^ symbol: variable Adaptiv location: class AdaptivTest
My class is 'test'
package io.adaptiv.plzwrk.lib; public class Adaptiv { public static int doStuff() { return 42; } }
The layout of my project is as follows

With .gradle settings
include ':lib'
Project build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
Build.gradle file under lib dir
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.1' } } apply plugin: 'com.android.library' repositories { jcenter() } android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 9 targetSdkVersion 22 versionCode 1 versionName "1.0" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { testCompile 'junit:junit:4.12' testCompile "org.mockito:mockito-core:1.9.5" }
kreek source share