Open albendz opened 2 weeks ago
Hi @albendz I am interested in this issue!
@andrewtavis Could you take a look at assigning this to @KesharwaniArpita ?
Thanks for the ping, @albendz :)
@KesharwaniArpita, could we ask you to send along a plan for this issue and we'll give you the ok to implement it? Please let us know if you need some support :)
CC @angrezichatterbox
HI @albendz @andrewtavis do you think if we should consider writing tests for the MainActivity
using mockk
to ensure the functionality works as expected without relying on actual dependencies? We can start by mocking components like SharedPreferences
, we can verify that user preferences, such as dark mode settings, are correctly applied in the applyUserDarkModePreference()
method. Does that sound good?
HI @albendz @andrewtavis do you think if we should consider writing tests for the
MainActivity
usingmockk
to ensure the functionality works as expected without relying on actual dependencies? We can start by mocking components likeSharedPreferences
, we can verify that user preferences, such as dark mode settings, are correctly applied in theapplyUserDarkModePreference()
method. Does that sound good?
Yes, It sounds good to me. You could write tests for the Main Activity as an example.
Terms
Description
Summary
The Scribe Android app supports unit testing with JUnit and mocking with MockK. Right now there aren't any test examples using mocking.
Add an example test that uses mocking.
Note that this may require some refactoring if you find you can't mock certain things or you're mocking a lot. For example, you cannot mock getting environment variables so that can be extracted into a separate class that itself can be mocked. I encountered this issue when I was attempting to write a unit test for one of the Activity classes.
Additional details
Here are some details related to mocking for Android: https://developer.android.com/training/testing/local-tests#mocking-dependencies
MockK documentation: https://mockk.io/
Contribution
I can pick this up later if no one else gets to it before I'm free