19

For last few weeks, I was using Appium(python) for android testing but yesterday we have decided to shift to Expresso(Java) for automated testing. There are couple of reasons why we are making this shift:

  • We want to scale out our automated testing, and there are lot of features not present in appium.

  • This is one of the latest testing framework for android, and has nice backward compatibility.

  • Small API and very easy to customize.

I have been reading for Espresso but I don't find anything great at all, If I compare it with Appium. I am a Python/R developer so maybe there are couple of points I am not able to understand. Would anyone like to help me understand if the shift to this new testing framework will be good for future? I am missing the bigger picture here, and any help would be greatly appreciated.

kiedysktos
  • 3,910
  • 7
  • 31
  • 40
python
  • 4,403
  • 13
  • 56
  • 103

4 Answers4

17
  1. The Shifting will be very much useful as Espresso supports testing activities outside the app like camera, browser and dialer etc which appium does not support.
  2. Espresso you can test toast message, auto complete and dialogs which are outside app.
  3. With Espresso Test Suit you can find code coverage and measure your testing efforts.
anuja jain
  • 1,367
  • 13
  • 19
  • 4
    I'm not sure you can test things outside of your app with Espresso. For that you would need to use something like ui-automator. See https://developer.android.com/training/testing/ui-testing/espresso-testing.html and https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html – Yair Kukielka Aug 13 '16 at 23:05
  • 2
    @YairKukielka That's true, Espresso does not support testing outside the app but it can work in tandem with UiAutomator. So, in the same test code, you can write Espresso as well as UiAutomator and so test in as well as outside the app. Reference: https://plus.google.com/+AndroidDevelopers/posts/WCWANrPkRxg – user846316 Sep 28 '16 at 08:33
  • 2
    you can use Espresso Intent to test Camera and phone's dialer activity outside of your app.That's what I meant in my answer. – anuja jain Sep 28 '16 at 11:19
  • One of the most important points in my opinion: You just can just test end-to-end / on integration level with Appium. These tend to be indeterministic, rendering the tests more or less useless in my opinion. Failures of the tests are hard to investigate. Furthermore: With complex workflows or with an increasing number of tests they simply don't scale. The solution would be to test component-wise (e.g. per Activity) which is much faster, reliable, traceable, adaptable (mochable), and so on. You can't do that with Appium. – nepa Jun 19 '17 at 13:38
13

You can go to Espresso if you're sticking only to Android automation and have no idea of automating iOS.

AFIKW, Espresso needs source code of the app in order to automate it.

Advantage is, it's directly open-sourced by google.

But my go is to go with Appium since its a large open sourced community with huge enhancements on its way and easy to automate with any programming language and needless to say it supports both Android and iOS.

kiedysktos
  • 3,910
  • 7
  • 31
  • 40
karthick23
  • 1,313
  • 1
  • 8
  • 15
8

I agree that Espresso may be be very efficient when it comes to Android testing solely. For example, it can run only the activity it's testing, which is great.

Still, I stick to the Appium because it has the same API for both AndroidDriver and iOSDriver. Usually Android apps are accompanied by iOS apps, and if you're responsible for the UI automation, you have to take overall costs into account.

Appium has following advantages over platform-specific solution:

  • Android and iOS tests can share many classes, including helper methods and configuration,
  • Android and iOS tests can share common tests logic on higher level, while having different or slightly different implementation on lower level (for example sometimes I can just copy whole page object class and make simple change of locators in order to make it work on the other platform),
  • same API enables us to seamlessly switch between the iOS and Android test development in a team. Easy switching to Selenium for Web development is additional benefit.

The biggest disadvantage of Appium is the speed of longer test scenarios and some difficulties in locating elements, but still it's my choice.

As the side note, I'd like to add that you shouldn't forget about the test pyramid which refers to test automation. Please keep balance between Unit Tests, Integration tests and UI tests http://martinfowler.com/bliki/TestPyramid.html

kiedysktos
  • 3,910
  • 7
  • 31
  • 40
6

The main difference between the two is,

Espresso test is within the application and it is aware of all the layers of the application. So you can mock certain layers of app, more like a white-box testing

Appium tests are black-box, tests know only the UI layer of the app. Main advantage is for cross-platform testing.

Santhosh Kumar
  • 314
  • 2
  • 9