Skip to content

dpreussler/mockitoid

Repository files navigation

Build Status Maven Central

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

About

Android specific assertions and mock for mockito

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages