All Projects → ragdroid → Mockstar

ragdroid / Mockstar

Licence: mit
Demo project on How to be a Mockstar using Mockito and MockWebServer.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Mockstar

Dagger2
Kotlin Dagger2 example project
Stars: ✭ 145 (+173.58%)
Mutual labels:  rxjava, dagger2, unit-testing, retrofit2
AndroidMVPArchitecture
Android MVP architecture sample project with or without RxJava and Dagger2 and Kotlin
Stars: ✭ 78 (+47.17%)
Mutual labels:  rxjava, mockito, dagger2, retrofit2
Fineract-CN-mobile
DEPRECATED project - Check the Apache fineract-cn-mobile project instead
Stars: ✭ 17 (-67.92%)
Mutual labels:  unit-testing, rxjava, dagger2, retrofit2
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (+54.72%)
Mutual labels:  rxjava, dagger2, mockito, retrofit2
Tvflix
TvFlix android app using Dagger Hilt, Coroutines, Flow, KTX, Jetpack(Room, ViewModel, Paging3, Lifecycle) based on MVVM architecture purely written in Kotlin
Stars: ✭ 286 (+439.62%)
Mutual labels:  dagger2, unit-testing, mockito, retrofit2
Kotlinrxmvparchitecture
Clean MVP Architecture with RxJava + Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Includes Unit Tests(Kotlin Tests)!
Stars: ✭ 94 (+77.36%)
Mutual labels:  rxjava, dagger2, unit-testing, retrofit2
Android tmdb clean architecture
Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Stars: ✭ 63 (+18.87%)
Mutual labels:  rxjava, dagger2, mockito, retrofit2
Androidstarter
A sample Android app using the MVP architecture.
Stars: ✭ 140 (+164.15%)
Mutual labels:  rxjava, dagger2, mockito, retrofit2
Star Wars Shop
Simple project with clean architecture and android lifecycle
Stars: ✭ 37 (-30.19%)
Mutual labels:  rxjava, dagger2, mockito, retrofit2
Kotlin Life
App界的一股清流 音视频vr应有尽有 完全按照Material design规范设计的App (written with java and Kotlin)
Stars: ✭ 864 (+1530.19%)
Mutual labels:  rxjava, dagger2, retrofit2
Bigbang
Android base project used by Xmartlabs team
Stars: ✭ 47 (-11.32%)
Mutual labels:  rxjava, dagger2, retrofit2
Afmall
A pure shopping App based on Kotlin + ARouter + MVP + RxJava2 + Retrofit + Dagger2 + 七牛云 + Glide
Stars: ✭ 20 (-62.26%)
Mutual labels:  rxjava, dagger2, retrofit2
BookReader
📕 "任阅" 网络小说阅读器,3D翻页效果、txt/pdf/epub书籍阅读、Wifi传书~
Stars: ✭ 6,113 (+11433.96%)
Mutual labels:  rxjava, dagger2, retrofit2
AndroidTutorials
Ejemplos Android [Dagger2,RxJava,MVP,Retrofit2,SQLite]
Stars: ✭ 22 (-58.49%)
Mutual labels:  rxjava, dagger2, retrofit2
BESTV
Android TV App powered by TMDb. It is a easy way to find the best TV content, the top movies, series... all of that in your TV.
Stars: ✭ 49 (-7.55%)
Mutual labels:  mockito, dagger2, retrofit2
Weather-Guru-MVP
Sample Material-design Android weather application build with MVP architectural approach using Dagger2, RxJava2, Retrofit2, Event-Bus, GreenDao, Butterknife, Lottie etc.
Stars: ✭ 15 (-71.7%)
Mutual labels:  mockito, dagger2, retrofit2
MockitoIn28Minutes
Learn Mockito from In28Minutes
Stars: ✭ 95 (+79.25%)
Mutual labels:  unit-testing, mocking, mockito
catchflicks
🎬 Kitchen sink project for learning android concepts 🎬
Stars: ✭ 12 (-77.36%)
Mutual labels:  rxjava, dagger2, retrofit2
Android App Template
Kickstart your new project with Android App Template (Kotlin + MVVM + AAC + Dagger 2 + Retrofit 2 + RxJava)
Stars: ✭ 34 (-35.85%)
Mutual labels:  rxjava, dagger2, retrofit2
Mockingbird
A convenient mocking framework for Swift
Stars: ✭ 302 (+469.81%)
Mutual labels:  unit-testing, mocking, mockito

mockstar

Demo project for using MockWebServer for unit tests. This project also hints on mocking out views while testing using Mockito and focuses on the usage of MockWebServer for writing tests.

Using MockWebServer for writing unit tests.

Most of the demos out there make use of MockWebServer for writing androidTests and adding custom JUnitTestRunners and are more focused on integration testing. Nowadays, MVP architecture is getting adopted by many android developers and we like our logic layer to be tested properly. MVP enables proper testing of the logic layer via unit tests and separates it from the pains of testing the android UI. While testing, we should not hit the actual web server. If we hit actual server while testing, then the tests become flaky as they depend upon the actual network availability. This project shows how we can write unit tests for our Presenters / Models easily. It also shows how we can test certain error conditions properly with the use of Mockito and MockWebServer which becomes as easy as just hitting the actual remote server.

Project implements the following :

Implementation

This project has a separate module called mocks. Our android application module app has a testCompile dependency on the mocks module. Also, created a LocalResponseDispatcher which takes care of the local API needs.

We use MockWebserver to test the API calls in our ModelRepository (PokemonDataSource) and we use Mockitoto test our Presenter (MainPresenterImpl) by mocking out the view. We have also written some demo tests using MockWebServer just to show how same thing can be achieved using MockWebServer also.

Model - PokemonDataSource -> PokemonDataSourceTest (uses MockWebServer) Presenter - MainPresenterImpl -> MainPresenterImplTest (uses MockWebServer) -> MainPresenterImplMockTest (uses Mockito)

To run tests : ./gradlew clean test

To-Do

  • More Documentation.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].