android - Robolectric With Gradle: .\res\values is not a directory -


i'm working on implementing running robolectric tests gradle.

i'm executing tests time try instantiate activity robolectric.buildactivity(classname.class).create().get();

edit: same error generated helloworld activity = new helloworld();

i'll following error:

 java.lang.runtimeexception: java.lang.runtimeexception: .\res\values not directory         @ org.robolectric.res.packageresourceloader.doinitialize(packageresourceloader.java:23)         @ org.robolectric.res.xresourceloader.initialize(xresourceloader.java:29)         @ org.robolectric.res.overlayresourceloader.doinitialize(overlayresourceloader.java:24)         @ org.robolectric.res.xresourceloader.initialize(xresourceloader.java:29)         @ org.robolectric.res.xresourceloader.getvalue(xresourceloader.java:53)         @ org.robolectric.res.overlayresourceloader.getvalue(overlayresourceloader.java:58)         @ org.robolectric.res.routingresourceloader.getvalue(routingresourceloader.java:31)         @ org.robolectric.shadows.shadowassetmanager.getandresolve(shadowassetmanager.java:263)         @ org.robolectric.shadows.shadowassetmanager.getandresolve(shadowassetmanager.java:259)         @ org.robolectric.shadows.shadowassetmanager.getresourcevalue(shadowassetmanager.java:85)         @ android.content.res.assetmanager.getresourcevalue(assetmanager.java)         @ android.content.res.resources.getvalue(resources.java:1009)         @ android.content.res.resources.loadxmlresourceparser(resources.java:2098)         @ android.content.res.resources.getlayout(resources.java:852)         @ android.view.layoutinflater.inflate(layoutinflater.java:394)         @ android.view.layoutinflater.inflate(layoutinflater.java:352)         @ org.robolectric.tester.android.view.robowindow.setcontentview(robowindow.java:82)         @ org.robolectric.shadows.shadowactivity.setcontentview(shadowactivity.java:272)         @ android.app.activity.setcontentview(activity.java)         @ at.inaut.hw.helloworldactivity.oncreate(helloworldactivity.java:13)         @ android.app.activity.performcreate(activity.java:5008)         @ org.fest.reflect.method.invoker.invoke(invoker.java:112)         @ org.robolectric.util.activitycontroller$1.run(activitycontroller.java:119)         @ org.robolectric.shadows.shadowlooper.runpaused(shadowlooper.java:256)         @ org.robolectric.util.activitycontroller.create(activitycontroller.java:114)         @ org.robolectric.util.activitycontroller.create(activitycontroller.java:126)         @ at.inaut.hw.helloworldtest.testinstantiation(helloworldtest.java:23) 

my gradle build

import java.util.regex.pattern  buildscript {     repositories {         mavencentral()     }      dependencies {         classpath 'com.android.tools.build:gradle:0.5.+'     } }  apply plugin: 'android'  android {        compilesdkversion 17        buildtoolsversion "17.0"      sourcesets {         main{            manifest.srcfile 'androidmanifest.xml'         }     } }  sourcesets {     unittest {         java.srcdir file('src/test/java')         resources.srcdir file('src/test/resources')     } }  configurations {     unittestcompile.extendsfrom runtime     unittestruntime.extendsfrom unittestcompile }   repositories {     mavencentral() }  dependencies {     compile project(':libs:actionbarsherlock') } sourcesets {     unittest {         java.srcdir file('test')         resources.srcdir file('test/resources')     } }  dependencies {     unittestcompile files("$project.builddir/classes/debug")     unittestcompile 'junit:junit:4.11'     unittestcompile 'org.robolectric:robolectric:2.1.1'     unittestcompile 'com.google.android:android:4.1.1.4'     unittestcompile files("${project(':libs:actionbarsherlock').builddir}/classes/debug") }  configurations {     unittestcompile.extendsfrom runtime     unittestruntime.extendsfrom unittestcompile     }      task unittest(type:test, dependson: assemble) {     description = "run unit tests"     testclassesdir = project.sourcesets.unittest.output.classesdir     classpath = project.sourcesets.unittest.runtimeclasspath     }  check.dependson unittest 

this code test throwing error

test causing error

activity =   robolectric.buildactivity(helloworldactivity.class).create().get();     testbtn = (button)activity.findviewbyid(r.id.btntest);     assertnotnull(testbtn);     assertthat(testbtn.gettext().tostring(), equalto("testme"));     assertnotnull(activity); 

could project structure? or way robolectric loading resources?

i able solve ./res/value issue changing project structure resemble

.project root ├── build.gradle ├── settings.gradle  ├── build └── src   └── main   |__res  └── test     └── src           └── java 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -