mockitoid

General

Category
Free
Tag
Object Mocking
License
MIT License
Registered
Dec 25, 2015
Favorites
0
Link
https://github.com/dpreussler/mockitoid
See also
mocker
DaggerMock
CursorMock
EasyMock
PowerMock

Additional

Language
Java
Version
0.7 (Jun 8, 2016)
Created
Dec 21, 2015
Updated
Apr 9, 2018 (Retired)
Owner
Danny Preussler (dpreussler)
Contributor
Danny Preussler (dpreussler)
1
Activity
Badge
Generate
Download
Source code

Show card

mockitoid

Android specific assertions and mocks for mockito for cleaner test code

Gradle

testCompile 'de.jodamob.android:mockitoid:0.7'
 

Asserts

write anyActivity() instead of any(Activity.class) in mockito verification.

example:

verify(myInteractor).showWizard(anyActivity());

Same with:

anyFragment()
anyFragmentManager()
anyIntent()
anyContext()
anyView()
anyButton()
...

more to be come

Mocks

write mockActivity() instead of mock(Activity.class) Same with:

mockFragment()
mockResources()
mockContext()
mockIntent()
mockBundle()
...

some mocks can have small behavior: mockTextView("test") given a Textview that will return an Editable that has string "test"

mockFragmentManager(FragmentTransaction) will return this fragmenttransaction for every transaction started

mockRecyclerView() will return a recyclerview that will remember adapter and laoutManager between set and get

mockMenuItem(id) where id will be the itemId that will return a MenuItem mock for ..

Licensed under MIT license (c) 2015-2016 Danny Preussler