-
Notifications
You must be signed in to change notification settings - Fork 249
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
testing: Utils test implemented in core module #420
Conversation
@jingtang10 @deepankarb i have implemented this testing file. Please review this pr. Thanks! |
import android.os.Build | ||
import java.time.ZoneId | ||
import java.time.format.DateTimeFormatter | ||
import java.util.* |
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.
Spotless check is failing most likely because of this.
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.
Thanks so much for the review @epicadk ! I have updated the changes, hope the build runs now. :)
@@ -1,5 +1,5 @@ | |||
/* | |||
* Copyright 2021 Google LLC |
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.
Why this change?
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.
thanks!
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.getDefault()) | ||
.withZone(ZoneId.systemDefault()) | ||
val expectedResult = simpleDateFormat.format(currentDate.toInstant()) | ||
assertEquals(currentDate.toTimeZoneString(), expectedResult) |
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.
We use Truth
: https://truth.dev/
@Config(sdk = [Build.VERSION_CODES.P]) | ||
class UtilTest { | ||
@Test | ||
fun checkTimeZoneFormat() { |
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.
fun checkTimeZoneFormat() { | |
fun shouldFormatDate() { |
class UtilTest { | ||
@Test | ||
fun checkTimeZoneFormat() { | ||
val currentDate = Date() |
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'd rather use a fixed value in test to avoid flakiness.
Is this still being worked on? |
Hi @jingtang10 I apologise for the delay. Sadly I had COVID for quite a while. I have just fully recovered. |
Hi @Ana2k - sorry to hear that you had covid but really pleased to hear that you're fully recovered. Please take it easy! Kind regards and best wishes to you! |
@jingtang10 theres some updates in the Util.kt file and its test file in the master branch. |
@jingtang10 I have updated the shouldFormatDate function in utilTest.kt Kindly please review. Thanks! |
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXXXX", Locale.getDefault()) | ||
.withZone(ZoneId.systemDefault()) | ||
val expectedResult = simpleDateFormat.format(parsedDate.toInstant()) | ||
assertThat(parsedDate.toString()).isEqualTo(expectedResult) |
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 are you testing here? I thought you wanted to test https://github.com/google/android-fhir/blob/master/engine/src/main/java/com/google/android/fhir/Util.kt#L30?
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.
Yes, these are the changes for the same.
The tests passed on my end.
Let me know if any issues exist or more changes are required.
@maimoonak tagging you to update about previous PR.
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'm not see the Date.toTimeZoneString
method being called here. How is it being tested?
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXXXX", Locale.getDefault()) | ||
.withZone(ZoneId.systemDefault()) | ||
val expectedResult = simpleDateFormat.format(parsedDate.toInstant()) | ||
assertThat(parsedDate.toString()).isEqualTo(expectedResult) |
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'm not see the Date.toTimeZoneString
method being called here. How is it being tested?
Hi @Ana2k , is there an ETA you can provide for completing the changes as per the review comments in order to close this PR? |
Hi @Tarun-Bhardwaj I am have almost completed working on this, ETA is around 11th August |
Closing this since it's not been worked on. |
IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straighforward changes).
Fixes #380
Description
Added UtilTest.kt file as unit test for Util.kt
Alternative(s) considered
N/A
Type
Choose one: Testing
Screenshots (if applicable)
N/A
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project./gradlew check
and./gradlew connectedCheck
to test my changes locally