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 tests for TextViewBindingAdapters #3846

Closed
BenHenning opened this issue Sep 26, 2021 · 4 comments · Fixed by #4060
Closed

Add tests for TextViewBindingAdapters #3846

BenHenning opened this issue Sep 26, 2021 · 4 comments · Fixed by #4060
Assignees
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@BenHenning
Copy link
Sponsor Member

TextViewBindingAdapters today doesn't have any tests for it, and ought to since it may not be obvious to track down future regressions that may occur in this file. These tests also ought to specifically test the binding adapters in their normal context (i.e. used through databinding with a test layout).

This also tracks adding new testing coverage after #3795 is merged since https://github.com/oppia/oppia-android/blob/baf7fd23affbf7dc27192a24fbb881e10519d2e7/utility/src/test/java/org/oppia/android/util/system/OppiaDateTimeFormatterTest.kt is being removed & its behaviors are now part of TextVIewBindingAdapters directly (so the same behaviors from that test suite should be added to the test suite for TextViewBindingAdapters).

@justdvnsh
Copy link
Contributor

@BenHenning I'd Like to work upon it.

@rt4914
Copy link
Contributor

rt4914 commented Nov 18, 2021

@rishidyno Unassigning you from this issue because of inactivity, please re-assign yourself if you are currently working on this.

@rishidyno rishidyno self-assigned this Dec 10, 2021
@rishidyno
Copy link
Contributor

rishidyno commented Dec 10, 2021

@rt4914 @BenHenning @anandwana001 do I need to create a layout file for TextViewBindingAdaptersTestActivity
like (eg:
test_image_view_bindable_adapter_activity was made for ImageViewBindingAdaptersTestActivity)

as for now, I have created a layout file for the same with a textview.

Also as I don't have much experience in writing tests. Could you please give me a few examples for writing tests for binding adpters and explain them to me. Also, are there any prerequisites like learning something new in particular for this PR, please let me know and suggest some resources for the same? Thanks.

@BenHenning
Copy link
Sponsor Member Author

@rishidyno you will need to create a test activity & layout (so that you have an easy-to-access TextView to test the adapters). In terms of how they work, I suggest looking at https://github.com/oppia/oppia-android/blob/develop/app/src/sharedTest/java/org/oppia/android/app/databinding/MarginBindingAdaptersTest.kt or other tests from that databinding package. Generally, the way we test binding adapters is by calling them directly to ensure that whatever they're supposed do/change actually happens.

In terms of actually writing tests, I suggest reading over https://github.com/oppia/oppia-android/wiki/Oppia-Android-Testing#learning-how-to-write-good-tests including the corresponding presentation, if you haven't already.

rt4914 pushed a commit that referenced this issue Feb 15, 2022
* first commit

* nitfix

* test added

* test added

* test file exemption

* format

* format

* added textviewbindingadapters in binding adapters in app bazel file

* removed

* commit

* fixed tests

* fixed tests

* fixed tests

* test

* test

* test

* test

* test

* test

* code format

* added label

* final

* few fixes

* nitfix

* nitfix

* added another test case

* update

* Update AndroidManifest.xml

* added test cases for profile last visited

* added textviewbindingadapterstestactivity to accessibility_label_exemptions.textproto

* added textviewbindingadapterstestactivity to accessibility_label_exemptions.textproto

* added textviewbindingadapterstestactivity to accessibility_label_exemptions.textproto

* format

* added all test cases for profile last visited

* added more test cases for profile last visited

* give more descriptive test names

* added recently srring resource

* nit-fix

* nit-fix

* nit-fix
@BenHenning BenHenning added the Z-ibt Temporary label for Ben to keep track of issues he's triaged. label Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Development

Successfully merging a pull request may close this issue.

4 participants