GithubHelp home page GithubHelp logo

chiuki / espresso-samples Goto Github PK

View Code? Open in Web Editor NEW
634.0 40.0 156.0 633 KB

A collection of samples demonstrating different Espresso techniques.

License: Apache License 2.0

Java 34.52% Kotlin 65.48%

espresso-samples's Introduction

Android Espresso Samples

A collection of samples demonstrating different Espresso techniques.

espresso-samples's People

Contributors

aumarbello avatar chiuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

espresso-samples's Issues

Feature Request

Blogpost or sample or writeup about MockWebServer to develop when back end api is not ready yet.

Value of ElapsedTimeIdlingResource?

Been thinking a lot about this recently because I've seen it in a few projects and I'm struggling to see what it offers over a simple Thread.sleep. The only context I can find is this blog post, which simply states "We could use SystemClock.sleep(60000), but that blocks the testing thread.". This is a strange justification since IdlingResources cause onView and onIdle to block the testing thread and this is wanted and expected behaviour for test code (tests are always run synchronously).
As far as I can tell using this IdlingResource is identical to using a sleep from a thread execution standpoint, but the code is more verbose and harder to understand. This seems to me like a misuse of IdlingResource and a testing anti-pattern, and it seems to be used in many codebases where a sleep would be simpler. Please let me know if there's some other execution property that makes this implementation advantageous.
Thanks.

Way to test multiple device test cases

Hi Chiuki, I was wondering is there a way to test, in espresso, scenarios like chat application, where you need two devices, one from you send message and on the other you receive the message and also assert for received push notifications? Seeking Help

ElapsedTimeIdlingResource no longer works with the new Espresso IdlingRegistry.

The former Espresso.registerIdlingResources() method has been deprecated in favor of using the new IdlingRegistry via getInstance().register(). However, after upgrading, my test no longer work using the ElapsedTimeIdlingResource.

        mElapsedTimeIdlingResource = new ElapsedTimeIdlingResource(3);
        getInstance().register(mElapsedTimeIdlingResource);
       // Do Something
        getInstance().unregister(mElapsedTimeIdlingResource);

Rotate screen tests failed on Android P Preview

I am running the tests using emulator, and I can see a dialog showing after the roatation. Here is the screenshot and log.
I assume it's the dialog that causes the app to not able to match id? How can we solve this? Thanks.
screenshot

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.sqisland.android.espresso.rotate_screen:id/count

View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=1553, height=660, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params={(0,0)(wrapxwrap) gr=CENTER sim={adjust=pan} ty=APPLICATION fmt=TRANSLUCENT wanim=0x10302f9
fl=DIM_BEHIND ALT_FOCUSABLE_IM SPLIT_TOUCH HARDWARE_ACCELERATED}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+->FrameLayout{id=-1, visibility=VISIBLE, width=1441, height=548, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@b572184, tag=null, root-is-layout-requested=false, has-input-connection=false, x=56.0, y=56.0, child-count=2}
|
+-->FrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=1441, height=548, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@24a3da2, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+--->AlertDialogLayout{id=16909154, res-name=parentPanel, visibility=VISIBLE, width=1441, height=548, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@392d68f, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=4}
|
+---->LinearLayout{id=16909416, res-name=topPanel, visibility=VISIBLE, width=1441, height=184, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@739defa, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+----->LinearLayout{id=16909406, res-name=title_template, visibility=VISIBLE, width=1441, height=156, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@2c066a1, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}
|
+------>AppCompatImageView{id=16908294, res-name=icon, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@cb6f0c6, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+------>DialogTitle{id=16908701, res-name=alertTitle, visibility=VISIBLE, width=1273, height=93, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@6650887, tag=null, root-is-layout-requested=false, has-input-connection=false, x=84.0, y=63.0, text=Rotate Screen, input-type=0, ime-target=false, has-links=false}
|
+----->Space{id=16909401, res-name=titleDividerNoCustom, visibility=VISIBLE, width=1441, height=28, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@107f3b4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=156.0}
|
+---->FrameLayout{id=16908808, res-name=contentPanel, visibility=VISIBLE, width=1441, height=168, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@8a15352, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=184.0, child-count=1}
|
+----->ScrollView{id=16909247, res-name=scrollView, visibility=VISIBLE, width=1441, height=142, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@80a9720, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+------>LinearLayout{id=-1, visibility=VISIBLE, width=1441, height=142, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@ad2054c, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=3}
|
+------->Space{id=16909383, res-name=textSpacerNoTitle, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@dd19995, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+------->AppCompatTextView{id=16908299, res-name=message, visibility=VISIBLE, width=1441, height=142, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@d47faaa, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=Detected problems with API compatibility
(visit g.co/dev/appcompat for more info), input-type=0, ime-target=false, has-links=false}
|
+------->Space{id=16909382, res-name=textSpacerNoButtons, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@f81b69b, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
+---->FrameLayout{id=16908815, res-name=customPanel, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@bff3a11, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+----->FrameLayout{id=16908331, res-name=custom, visibility=VISIBLE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@9831776, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0}
|
+---->ScrollView{id=16908761, res-name=buttonPanel, visibility=VISIBLE, width=1441, height=196, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=true, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@b69b1e4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=352.0, child-count=1}
|
+----->ButtonBarLayout{id=-1, visibility=VISIBLE, width=1441, height=196, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@c461a49, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=4}
|
+------>AppCompatButton{id=16908315, res-name=button3, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@3519f4e, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|
+------>Space{id=16909318, res-name=spacer, visibility=INVISIBLE, width=1133, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@c9ec86f, tag=null, root-is-layout-requested=false, has-input-connection=false, x=42.0, y=182.0}
|
+------>AppCompatButton{id=16908314, res-name=button2, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=true, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@587597c, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|
+------>AppCompatButton{id=16908313, res-name=button1, visibility=VISIBLE, width=224, height=168, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@9cd1205, tag=null, root-is-layout-requested=false, has-input-connection=false, x=1175.0, y=14.0, text=OK, input-type=0, ime-target=false, has-links=false}
|
+-->ViewStub{id=16908682, res-name=action_mode_bar_stub, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, layout-params=android.widget.FrameLayout$LayoutParams@cac625a, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0}
|
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:90)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:291)
at com.sqisland.espresso.rotate_screen.MainActivityTest.noIncrementRotateScreen(MainActivityTest.java:61)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2136)

okhttp:2.4.0

Is it possible to use the library with com.squareup.okhttp:okhttp:2.4.0?
There is a lot of legasy code that I don't whant to change to okhttp 3 for now.

Need a helper method to clear app data and then continue running test cases

Just like the rotate-screen method you have created can you help me in creating a method to clear user data(Which should work same as going to app info>>storage>>clear data)
I am trying to automate the Onboarding process and need to clear app data before each test run.
So far I have found ways to run adb commands to clear data but using that closes the app thus failing the tests.
I need to use the method in @before of the test suite so that before each test execution the data is cleared.

How to understand the default synchronization function of Espresso

Hello,I see the following content written on your blog
2017-08-01 9 30 48
How to understand the default synchronization function of Espresso
for example ,I use Handler send a message to UI thread , is there a UI event in the current message queue?
And what is the default AsyncTask thread pool meaning(use the class of AsyncTask in your app)?
Looking forward to your answer @chiuki thanks

Feature request: Dialog by instanceOf not just tag.

Hello,
What do you think of a idling resource that you could use for all your espresso tests that checks
getFragmentManager().getFragments() and iterates through seeing if any of them are LoadingDialogFragment - rather than having to register and unregister before every time a spinner pops up, just register in before and unregister in after?

Since any spinner means the app is not idle, rather than a specific spinner?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.