blipinsk/cortado
关于
让 Android Espresso 的使用更流畅 :coffee:
开发工具可以做什么
- Creating an instance of org.hamcrest.Matcher<View> org.hamcrest.Matcher<View> matcher = Cortado.view().withId(R.id.example);
- Creating an instance of android.support.test.espresso.ViewInteraction ViewInteraction viewInteraction = Cortado.onView().withId(R.id.example).perform(click());
- Fluently creating Matchers.allOf(...) Cortado.view().withId(R.id.example).and().withText("example").and().isClickable();
- Fluently creating Matchers.anyOf(...) Cortado.view().withId(R.id.example).or().withText("example").or().isClickable();
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Android Espresso made more fluent :coffee:
Check out my blog :squirrel: or say hi on Twitter.
Overview
Cortado provides a layer of abstraction above Espresso, so it's a bit easier to use.
Remember: It is Google Espresso underneath. You can still mess up your tests the same way you would when using pure Espresso. Cortado just gives you a bit nicer way to communicate with Espresso.
Espresso vs. Cortado
- Get a
Matcherforclickableviews withR.id.textand with text NOT "Example"
| Framework | Code example |
|---|---|
| Espresso | Matchers.allOf(withId(R.id.text), isClickable(), Matchers.not(withText("Example"))); |
| Cortado | Cortado.view().withId(R.id.text).and().isClickable().and().not().withText("Example"); |
- Get a
Matcherfor views that have textexampleor have parentFrameLayout
| Framework | Code example |
|---|---|
| Espresso | Matchers.anyOf(withText("example"), withParent(isAssignableFrom(FrameLayout.class))); |
| Cortado | Cortado.view().withText("example").or().withParent(isAssignableFrom(FrameLayout.class)); |
- Click on a
ViewwithR.id.button
| Framework | Code example |
|---|---|
| Espresso | Espresso.onView(withId(R.id.button)).perform(ViewActions.click()); |
| Cortado | Cortado.onView().withId(R.id.button).perform().click(); |
- Check if a
Viewwith textexampleis visible
| Framework | Code example |
|---|---|
| Espresso | Espresso.onView(withText("example")).check(ViewAssertions.matches(isDisplayed())); |
| Cortado | Cortado.onView().withText("example").check().matches(isDisplayed()); |
- Replace a text on
enabledview withR.id.edit
| Framework | Code example |
|---|---|
| Espresso | Espresso.onView(Matchers.allOf(withId(R.id.edit),isEnabled())).perform(ViewActions.replaceText("changed")); |
| Cortado | Cortado.onView().withId(R.id.edit).and().isEnabled().perform().replaceText("changed"); |
Features
Creating an instance of
org.hamcrest.Matcher<View>org.hamcrest.Matcher<View> matcher = Cortado.view().withId(R.id.example);Creating an instance of
android.support.test.espresso.ViewInteractionViewInteraction viewInteraction = Cortado.onView().withId(R.id.example).perform(click());Fluently creating
Matchers.allOf(...)Cortado.view().withId(R.id.example).and().withText("example").and().isClickable();Fluently creating
Matchers.anyOf(...)Cortado.view().withId(R.id.example).or().withText("example").or().isClickable();Fluently negating conditions
Cortado.view().not().withId(R.id.example).and().withText("example").and().not().isClickable();Fluently performing single action (on
ViewInteraction)Cortado.onView().withId(R.id.example).perform().click();Fluently checking matches (on
ViewInteraction)Cortado.onView().withId(R.id.example).check().matches(Cortado.view().withText("example"));
Compatibility
I wanted the api of Cortado to be compatible with Espresso as much as possible. That's why you can do stuff like that:
Espresso.onView(Cortado.view().withId(R.id.example).and().withText("Example")).perform(click());
Including In Your Project
dependencies {
androidTestImplementation 'com.bartoszlipinski:cortado:1.2.0'
}
Developed by
- Bartosz Lipiński
License
Copyright 2017 Bartosz Lipiński
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
探索相关项目
加载中…