-
-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Koin 1.0] Testing improvements with declareMock() & declare() #151
Comments
Nice, |
Hi @arnaudgiuliani Writing two tests (first fails, second succeeds)
I found a way to succeed but is-it an undocumented feature(AKA bug) or the behavior you expect ? |
Thanks for your feedback! Yeah, it's because I've added a fix. To override your definition |
since |
Nice and clear, |
Thanks Arnaud, |
Cool :) |
Sample updated with declareMock. |
Hello @arnaudgiuliani i am facing aproblem i have updated to the latest V3 and my test are not running because of the declare method. I am attaching you the code currently using fun createUserScopeFor(username: String): Scope { and then trying to run a RxChain for a purpose when it reaches the create userScope it throughs a null pointer which comes when the code riches the declare function. My test is like this
And i am mocking the koin thingies like follow whenever(koin.createScope(Scopes.USER_SESSION, named(Scopes.USER_SESSION))).thenReturn( where user scope is mock() and If i memove the declare(UserIdentifier(username)) then the test is running properly. Could you please provide me with some hints how this could be done |
Hello,
koin-test
will no rely on mockito to provide out of the box mocking.You can now directly declare a mock from a
KoinTest
file withdeclareMock()
:You can also declare some components with
declare { }
, if you need more complex expression:No need to declare a special module, if you have only local expressions/mocks.
Available in
koin-test
version1.0.0-beta-1
.The text was updated successfully, but these errors were encountered: