Mocktrofit


Source link: https://github.com/vokal/Mocktrofit

Mocktrofit

Mocking Client for Retrofit

Common Usage

Include the mocktrofit gradle plugin in buildscript

classpath 'io.vokal.gradle:mocktrofit-processor:0.1.2' 

Apply the plugin

apply plugin: 'io.vokal.mocktrofit' 

Retrofit 2 Usage

Include Mocktrofit

compile 'io.vokal.mock:mocktrofit2:1.0.0' 

Use the Client

  OkHttpClient mockClient = OkHttpClient.Builder()

 .addInterceptor(new OkMockInterceptor(ctx, "mocks"))

 .build();

 Retrofit retrofit = new Retrofit.Builder()

 .baseUrl(MockServer.BASE_URL)

 .setClient(mockClient)

 .build();

Retrofit 1 Usage

Include Mocktrofit

compile 'io.vokal.mock:mocktrofit:1.0.0' 

Use the Client

  RestAdapter restAdapter = new RestAdapter.Builder()

 .setEndpoint(MockClient.BASE_URL)

 .setClient(new MockClient(getContext(), "mocks"))

 .build();
 

Notes

If you are unsure what to name your mocks, check the logs. It will include both the expected name and the hash in case the filename is too long for your file system.

Limitations

Mocktrofit utilizes the names of mock files to determine the path and parameters of the request. Due to limitations in the Android Asset system, we need a compile time processor to hash the names such that the name is always a consistent length. Because of this, there are still some unimplemented features that VOKMockUrlProtocol has.

Implemented

  • Basic Mocks ending with .http
  • Mocks in both App and Test applications will work properly
  • Double hashing for long names (Most operating systems have a 255 character limit)

Unimplemented

  • .json and .xml file names
  • Fallback hashing of body and path

Resources

This library helps users to use Bottom Navigation Bar and allows ton of customizations.

An implementation of Cassowary, a linear constraint based layout manager for Android.

Adapter and LayoutManager for Android RecyclerView which enables sticky header positioning.

A Library to show Round ImageView with Face Detection and text labels on right side. Best suited for person details.

OAuth RxJava extension for Android.

This library helps to display overlapping views (topmost) in order to show some kind of message to capture user attention. It can be an error, success message, loading bar or just simple text message.

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