Espresso
psrc/androidTest/java
pAndroid Test Support Library
9
@RunWith(AndroidJUnit4.class)
public class MyEspressoTest {
@Rule
public ActivityTestRule<...>
activityActivityTestRule = ...;
...
}
Slide 10
Slide 10 text
Espresso API
OK
perform()check()
10
onView(ViewMatcher)
.perform(ViewAction)
.check(ViewAssertion);
p ViewMatcher
View
p ViewAction
p ViewViewAssertion
Slide 11
Slide 11 text
Espresso API
API
https://goo.gl/hx6YPo
11
onView(ViewMatcher)
.perform(ViewAction)
.check(ViewAssertion);
p ViewMatcher
View
p ViewAction
p ViewViewAssertion
IdlingRegistry I P
pIdlingRegistry: Espresso 3.0
p API:
pEspresso.registerIdlingResources()
pEspresso.unregisterIldingResources()
p ) ./7 / :/.
p ) A
p /
1::7 ( /: / 66 4/ 65
30
43
@After public void tearDown() {
registry.unregister(resource);
RxJavaPlugins.reset();
}
Slide 44
Slide 44 text
: A
RxJava A)
44
// (
// A ) )
@Rule public
ActivityTestRule activityRule
= new ActivityTestRule<>(
MyActivity.class, false, false);
@Before public void setUp() {
... // A)
registry.register(resource);
activityRule.launchActivity(null); }
UI Automator
p
com.android.support.test.uiautomator:
uiautomator-v18:2.1.3
p @Before
66
private UiDevice uiDevice;
@Before
public void setUp() throws Exception {
uiDevice = UiDevice.getInstance(
InstrumentationRegistry
.getInstrumentation());
}
Slide 67
Slide 67 text
UI Automator
#
p $ )uiDevice.wait()#
p Until
%"!&
pfindObject()
pfindObjects()
pgone()
phasObject()
67
uiDevice.wait('%",
()
Slide 68
Slide 68 text
UI Automator: Tips
68
/** I */
String toResName(int resId) {
return InstrumentationRegistry
.getTargetContext()
.getResources()
.getResourceName(resId);
}
ID(int)UI
p UI Automator D
p ID I
pIdlingResource#*
!
p),"%'
p
(
UI AutomatorAPI&+$
71
Slide 72
Slide 72 text
URL
p Kenta Kase RxJava
Espresso
in DroidKaigi Prelude
https://goo.gl/zUQEFi
p Iñaki VillarEspresso, Beyond the basicsin
360|AnDev 2017
https://goo.gl/FG7sLf
p Espresso 3.0.1
p https://goo.gl/VidZGa (espresso-core)
p https://goo.gl/aMUS5n (espresso-idling-resource)
p Espresso Idling Resources
https://goo.gl/PGzjWe
72
Slide 73
Slide 73 text
&!URL ($,)
p RxJava-(
)Espresso
" in Rx Ja Night Vol.2
h;ps://goo.gl/GBG8r1
p %.
Espresso+'*"
in DroidKaigi 2017
h;ps://goo.gl/D73jBN
p %
UI Automator# in
DroidKaigi 2016
h;ps://goo.gl/NQV8GP
73