i have instrumental test located @ app/androidtest/java/myapp. have 1 simple test method in there:
public class loginactivitytest { private static final string email = "admin@gmail.com"; private static final string password = "admin"; @rule public intentstestrule<loginactivity> loginactivity = new intentstestrule<>(loginactivity.class); @test public void loginwithpropercredentials() { onview(withid(r.id.email_textview)) .perform(typetext(email)); onview(withid(r.id.password_login)) .perform(typetext(password)); onview(withid(r.id.email_sign_in_button)) .perform(click()); intended(allof( hasextra(generalconstants.authenticated, true), hasextra(generalconstants.token, isa(string.class)), topackage("myapp"))); } } i have upgraded android support repository, added neccessary androidtestcompile dependencies default testinstrumentationrunner ("android.support.test.runner.androidjunitrunner") , i've chosen android instrumentation tests build variant. yet, attempting launch test gives me resourcenotfoundexception. i've figured out, it's setcontentview() method in oncreate(bundle bundle) throws exception.
i'm being struggling while now. reason it?
edit:
i've checked in myapp.test.r there missing field causing resourcenotfoundexception. field in myapp.r, has different value assosiated (0x7f040015 , 0x7f030015 in test.r-this 1 missing). i've tried explicitly import:
import pl.kawowydzienniczek.kawowydzienniczek.test.r; but trying write:
onview(withid(r.id.email_textview)) .perform(typetext(email)); gives me error saying email_textview cannot resolved. how should done?
edit2:
i've noticed commenting out following dependency
androidtestcompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
makes work. should okay, why , how make espresso work without throwing library out?
according to
for should okay, why , how make espresso work without throwing library out?
here's build.gradle config:
dependencies { ext.junit_version = '4.12' ext.support_version = '24.1.1' ext.espresso_version = '2.2.2' compile filetree(dir: ulibs', include: ['*.jar']) testcompile "junit:junit:$junit_version" testcompile("org.robolectric:robolectric:3.0") { exclude module: 'classworlds' exclude module: 'commons-logging' exclude module: 'httpclient' exclude module: 'maven-artifact' exclude module: 'maven-artifact-manager' exclude module: 'maven-error-diagnostics' exclude module: 'maven-model' exclude module: 'maven-project' exclude module: 'maven-settings' exclude module: 'plexus-container-default' exclude module: 'plexus-interpolation' exclude module: 'plexus-utils' exclude module: 'wagon-file' exclude module: 'wagon-http-lightweight' exclude module: 'wagon-provider-api' } compile "com.android.support:appcompat-v7:$support_version" compile "com.android.support:design:$support_version" androidtestcompile 'com.android.support.test:runner:0.5' androidtestcompile "com.android.support:support-annotations:$support_version" androidtestcompile "com.android.support.test.espresso:espresso-core:$espresso_version" androidtestcompile "com.android.support.test.espresso:espresso-intents:$espresso_version" /** * accessibilitychecks * countingidlingresource * draweractions * drawermatchers * pickeractions (time , date picker) * recyclerviewactions */ androidtestcompile("com.android.support.test.espresso:espresso-contrib:$espresso_version") { exclude group: 'com.android.support', module: 'appcompat' exclude group: 'com.android.support', module: 'support-v4' exclude group: 'com.android.support', module: 'support-v7' exclude group: 'com.android.support', module: 'design' exclude module: 'support-annotations' exclude module: 'recyclerview-v7' } compile "junit:junit:${junit_version}" } try exclude same groups modules , groups i've done.
check: https://github.com/piotrek1543/localweather/blob/master/app/build.gradle
hope help
Comments
Post a Comment