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 :-)
 

13 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
  5. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...
    Mobile App Development Company
    Mobile App Development Companies

    ReplyDelete
  6. Thanks for posting useful information.You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...Really it was an awesome article...very interesting to read..
    please sharing like this information......
    Android training in chennai
    Ios training in chennai


    ReplyDelete

  7. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Android App Development Company

    ReplyDelete
  8. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  9. 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
  10. This comment has been removed by the author.

    ReplyDelete