Skip to content
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

Add basic unit test structure #95

Merged
merged 1 commit into from
Mar 25, 2020
Merged

Add basic unit test structure #95

merged 1 commit into from
Mar 25, 2020

Conversation

utzcoz
Copy link
Contributor

@utzcoz utzcoz commented Mar 25, 2020

Selecting robolectric as unit test library to test UI on JVM. We use the
robolectric version 4.3.1, that supports to latest Android Q(final). But
it requires Java 9 to run the tests, so to avoid this problem, we assign
the sdk to 28 in robolectric.properties for almost all tests, and
leaving Android 10 specific features left to ease the usage of
robolectric.

Now we add a test example for U.java getTaskbarPosition function.

For check the tests result, we can execute ./gradlew test on the top
code directory, or use ctrl + shift + F10 in test file to execute unit
test in Android Studio.

For robolectric Java 9 discussion, we can see the link SO Does Robolectric require Java 9?

@farmerbb Taskbar is a large app now, maybe we should integrate tests to ensure
app function. And unit test is a good start.

Selecting robolectric as unit test library to test UI on JVM. We use the
robolectric version 4.3.1, that supports to latest Android Q(final). But
it requires Java 9 to run the tests, so to avoid this problem, we assign
the sdk to 28 in robolectric.properties for almost all tests, and
leaving Android 10 specific features left to ease the usage of
robolectric.

Now we add a test example for U.java getTaskbarPosition function.

For check the tests result, we can execute ./gradlew test on the top
code directory, or use ctrl + shift + F10 in test file to execute unit
test in Android Studio.

Signed-off-by: utzcoz <utzcoz@outlook.com>
@utzcoz
Copy link
Contributor Author

utzcoz commented Mar 25, 2020

@farmerbb Also unit test can run on pure JVM on the CI machine, and we can use it to check every modification.

@utzcoz
Copy link
Contributor Author

utzcoz commented Mar 25, 2020

The test result is generated to app/build/reports/tests/testFreeDebugUnitTest/.

@farmerbb
Copy link
Owner

Thanks for adding this. I'm pretty familiar with Robolectric and I agree that it's the right choice for testing this project. (I hadn't done any unit testing for Taskbar just because it's so tightly coupled with the Android framework, but there is quite a bit that could be tested here.)

I'll add the necessary stuff to integrate this with CI soon. Thanks again!

@farmerbb farmerbb merged commit d025b33 into farmerbb:master Mar 25, 2020
@utzcoz
Copy link
Contributor Author

utzcoz commented Mar 25, 2020

Okay, I will continue to do little code clean with relative tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants