-
Notifications
You must be signed in to change notification settings - Fork 52
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
Set up local unit testing in Scribe Android App #181
Comments
CC @angrezichatterbox for this conversation :) From my side, adding a dependency for JUnit 5 is not a problem and that sounds good to me. For MockK vs. Mockito, I'll take another look, but better developer experience definitely would be a factor, and that MockK is written in Kotlin (though I understand that the difference isn't as much as for iOS languages). Really appreciate your willingness to help here, @albendz! |
I'd love to help contribute to tests, but I do see that @albendz is taking care of the addition of the framework. I have experience with JUnit 4&5, MockK, and Mockito. |
I think MockK would be a good choice for our project. Since we are already working in Kotlin using MockK will give a better developer experience. Unlike Mockito, which requires additional dependencies for proper integration with Kotlin, MockK is specifically designed for Kotlin and doesn’t have those extra requirements. Additionally, MockK’s syntax is easier to read and maintain. Also Mockk has support for mocking final classes and methods. I would love to hear what everyone else feels about this. @andrewtavis @growabeard @albendz |
Sounds good to me, @angrezichatterbox! Thanks for the research effort! :) So decision is JUnit 5 and MockK 😊 |
Assigning @albendz for adding these into the project, and then we can discuss how we want to structure implementing individual tests :) |
Sounds good! |
Terms
Description
Summary
Select unit testing and mocking frameworks for local unit tests in the Scribe Android application and add unit tests to the codebase.
Details
Local unit tests provide a way to test individual classes or functions at build time to verify expected functionality. For example, testing both branches of an
if... else
. These tests are faster than manual or automated UI tests and are particularly useful when refactoring to assert behavior is the same before and after refactoring.Additional details on local unit tests: https://developer.android.com/training/testing/local-tests
As an Android application, JUnit is commonly used for local unit tests.
There are two versions of JUnit in use - JUnit 4 (legacy) and JUnit 5 (latest). Android testing dependencies only supports JUnit 4 and there is an additional third-party dependency you can add to use JUnit 5 instead: https://github.com/mannodermaus/android-junit5. Additionally, instrumentation tests for Android using Espresso require JUnit 4: https://developer.android.com/training/testing/instrumented-tests
If it is acceptable to add the third-party dependency to the project, I recommend JUnit 5.
Additional reading on JUnit 5 support for Android: android/android-test#224
Mocking is used to to mock or fake behavior of class dependencies to isolate the test scope. There are two candidate mocking frameworks for Android Kotlin:
MockK has slightly better support for mocking when writing Kotlin code but there isn't a significant difference between the two in terms of what they support. Mockito is more widely used as one of the more established Java test mocking frameworks.
Contribution
I'm happy to take this on as soon as the maintainers let me know which frameworks are preferred for this project. Feel free to assign to me when ready.
The text was updated successfully, but these errors were encountered: