Tuesday 19 January 2016

How to Setup Espresso for functional Testing?



You are reading this post because you want to go with Espresso Framework for your functional testing.The framework is very flexible and allows you to test different functionality with ease and accuracy.Let us get to the point and start configuring your project with espresso.
To configure Espresso within your Android Project is very simple and quick. By the end of this post you will be able to start writing your tests. In case you face any issues post it here.

Introduction to Espresso Video Tutorial -


Espresso Setup Step by Step Video Tutorial -


1.Espresso works in the same project where your app is build, so first step is to open your project.

2. Open file build.gradle inside- project -> App -> build.gradle and add below line of code at the end.


 

dependencies {
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile 'com.android.support.test:runner:0.5',{
        exclude group: 'com.android.support', module: 'support-annotations'
    }
}
android {
    defaultConfig {
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
    }
}

3. Then click on sync gradle, once the build is successful you are all set to write Espresso test cases. 

Note - 
add below code the defaultConfig before running the test case -

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 
Note - Learn More About Android Studio HERE 
 
 
I hope this post helps you find your code coverage for your test suit :)
Please Share your feedback in comments section below and follow QA Automated to get latest post update.Happy Testing :-)
 

24 comments:

  1. Will this Espresso works on existing APK files? Like I want to test the Gmail app. Is it possible to test the app without having the code of Gmail app?

    ReplyDelete
    Replies
    1. The Espresso is integrated with app's code and so it is not possible to use Espresso without app code.

      Delete
  2. Excellent read. Thanks for sharing information software testing. Now Indium software hiring Mobile App Testing Engineers (while you can)

    ReplyDelete
  3. Thanks for your effort very good information, it is very useful everyone.
    In my project after gradle sync i am getting this error "Error:Failed to resolve: org.ccil.cowan.tagsoup:tagsoup:1.2" please help you to fix this issue.

    ReplyDelete
  4. Hi,

    Thanks for visiting my blog. I feel this error is due to other dependency in ur project. try to use multidexenabled true

    Thanks & Regards,
    Anuja

    ReplyDelete
    Replies
    1. Hi Anuja

      I would like to learn espresso for industry purpose. Can you share me the links on my mailid (nikhilmit.k@gmail.com), from where could i learn it.

      Regards
      Nikhil Mittal

      Delete
  5. I am looking for some good blog sites for studying. I was searching over search engines and found your blog site. Well i like your high quality blog site design plus your posting abilities. Keep doing it.

    PSD to Wordpress
    wordpress website development

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. I am happy to find this post Very useful for me, as it contains lot of information

    Selenium Courses in Chennai

    Selenium training Chennai

    ReplyDelete
  8. Really nice topics you had discussed above. I am much impressed. Thank you for providing this nice information here.
    Mobile Game Testing

    Gameplay Testing

    Switch Game Testing

    ReplyDelete
  9. First time getting to know about Espresso Framework and really happy to see such information which helpful for me to know more about testing process
    great work

    ReplyDelete
  10. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery

    ReplyDelete
  11. Very interesting blog post. Quite informative and very helpful.This indeed is one of the recommended blog for learners. Thank you for providing such nice piece of article. I’m glad to leave a comment. Expect more articles in future Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery

    ReplyDelete
  12. Hi Anuja,

    Please help me ...
    I am getting below error after adding dependencies and click of sync


    Could not find method androidTestCompile() for arguments [com.android.support.test.espresso:espresso-core:2.2.2, build_eshianpvl1s4s1cqz2nj7bjva$_run_closure1$_closure3$_closure4$_closure6@3843637b] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
    Open File

    ReplyDelete
  13. Hi, can you please explain espresso set-up for Katalon Studio ?

    ReplyDelete