-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Reworked FieldListUpdateTest #6400
Conversation
..._app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java
Outdated
Show resolved
Hide resolved
..._app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java
Show resolved
Hide resolved
..._app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.java
Show resolved
Hide resolved
...ct_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FieldListUpdateTest.kt
Outdated
Show resolved
Hide resolved
@@ -84,38 +85,44 @@ class FieldListUpdateTest { | |||
|
|||
@Test | |||
fun changeInValueUsedInLabel_ShouldChangeLabelText() { | |||
val name = UUID.randomUUID().toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the advantage of using random answers here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a constant here could potentially make the tests less reliable, as the same constant might be used in the logic, causing the test to always pass. However, the main reason I kept the random names was to avoid making significant changes to the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer leaving them in. I totally understand that there's a benefit to random input data, but I don't think it's huge here, and it makes the tests less readable (to me anyway) and also makes me worry about why UUIDs are being used.
Down the line we could experiment with helpers to generate random data like names and numbers etc that would fit better in tests. That's a pretty common approach I've used on other projects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…uired_ShouldUpdateTheRelatedRequiredQuestion test
bf5cb43
to
1a354e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #6143
Why is this the best possible solution? Were any other approaches considered?
As outlined in the issue, the primary objectives were to refactor the entire test class to utilize
FormEntryActivityTestRule
and to update the recently added test (changeInValueUsedToDetermineIfAQuestionIsRequired_ShouldUpdateTheRelatedRequiredQuestion
) to use its own form. I also took the opportunity to add some further refactoring to enhance the tests.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
It doesn't require testing.
Do we need any specific form for testing your changes? If so, please attach one.
No.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest