Cortado


Source link: https://github.com/blipinsk/cortado

Android Espresso made more fluent ☕?

Check out my blog 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

  1. Get a Matcher for clickable views with R.id.text and 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");
  1. Get a Matcher for views that have text example or have parent FrameLayout
Framework Code example
Espresso Matchers.anyOf(withText("example"), withParent(isAssignableFrom(FrameLayout.class)));
Cortado Cortado.view().withText("example").or().withParent(isAssignableFrom(FrameLayout.class));
  1. Click on a View with R.id.button
Framework Code example
Espresso Espresso.onView(withId(R.id.button)).perform(ViewActions.click());
Cortado Cortado.onView().withId(R.id.button).perform().click();
  1. Check if a View with text example is visible
Framework Code example
Espresso Espresso.onView(withText("example")).check(ViewAssertions.matches(isDisplayed()));
Cortado Cortado.onView().withText("example").check().matches(isDisplayed());
  1. Replace a text on enabled view with R.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

  1. Creating an instance of org.hamcrest.Matcher<View>

    org.hamcrest.Matcher<View> matcher = Cortado.view().withId(R.id.example);
    
  2. Creating an instance of android.support.test.espresso.ViewInteraction

    ViewInteraction viewInteraction = Cortado.onView().withId(R.id.example).perform(click());
    
  3. Fluently creating Matchers.allOf(...)

    Cortado.view().withId(R.id.example).and().withText("example").and().isClickable();
    
  4. Fluently creating Matchers.anyOf(...)

    Cortado.view().withId(R.id.example).or().withText("example").or().isClickable();
    
  5. Fluently negating conditions

    Cortado.view().not().withId(R.id.example).and().withText("example").and().not().isClickable();
    
  6. Fluently performing single action (on ViewInteraction)

    Cortado.onView().withId(R.id.example).perform().click();
    
  7. 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 {

  androidTestCompile '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. 

Resources

Yet another floating search view implementation, also known as persistent search: that implementation fully supports menu (including submenu), logo and animated icon. Dropdown suggestions are backed by a RecyclerView and you can provide your own RecyclerView.Adapter, ItemDecorator or ItemAnimator.

An implementation of ProgressHUD for Android, similar to MBProgressHUD, SVProgressHUD.

IntlNumberInput is a custom view for Android that allows the user to enter his phone number in an elegant and friendly way. It adds a flag dropdown to any input, automatically detects the user's country, displays a relevant placeholder and auto formats the number as they type.

Reactive extension for Google's Smart Lock for Passwords API.

Its a kind of toolkit to track the exception arising in the application and it will generate a json and can upload in your server using your own post url.

Android drawable that allows you custom round rect position, with more friendly and flexible API.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes