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 to HealthKit Visualizations #49

Merged
merged 3 commits into from
Mar 8, 2024
Merged

Add Tests to HealthKit Visualizations #49

merged 3 commits into from
Mar 8, 2024

Conversation

YurenSUN
Copy link
Contributor

@YurenSUN YurenSUN commented Mar 6, 2024

Add Tests to HealthKit Visualizations

♻️ Current situation & Problem

Currently, we are missing test coverages for HealthKit visualizations, especially for the codes requiring access to the HealthKit data. This PR aims to cover those codes by (1) grouping codes parsing the HealthKit data as single functions to be tested with unit tests, and (2) using mock data for testing. Currently, we are still missing code coverage for reading HKStatistics as we are not able to manually initialize this class, and some auxiliary codes such as setting the states with parsed HealthKit, but the majority of the codes are covered. Overall, 402 out of 472 (~85%) lines for HealthKit visualization are now covered.

⚙️ Release Notes

  • Refactor part of the codes to group codes parsing the HealthKit data as single functions
  • Add unit tests for functions that parse the HKQuantity(s)
  • Add a feature flag --mockTestData to define whether we need to use the mock data for testing
  • Update the UI test to use the mock test data
  • Add codes to tap on screens to trigger and verify lollipops and details showings for the visualizations during UI tests.

📚 Documentation

Related comments are added.

✅ Testing

Unit tests and UI tests are added.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 68.67470% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 36.38%. Comparing base (380ea88) to head (4b96083).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
+ Coverage   31.20%   36.38%   +5.18%     
==========================================
  Files          54       54              
  Lines        2930     2961      +31     
==========================================
+ Hits          914     1077     +163     
+ Misses       2016     1884     -132     
Files Coverage Δ
PICS/HealthVisulization/HKVisualizationItem.swift 96.38% <100.00%> (+56.78%) ⬆️
PICS/HealthVisulization/HKVisualization.swift 77.42% <68.30%> (+11.44%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 380ea88...4b96083. Read the comment docs.

@YurenSUN YurenSUN requested a review from akanshyabhat March 7, 2024 16:18
Copy link
Contributor

@akanshyabhat akanshyabhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for adding tests!

@YurenSUN YurenSUN merged commit a7c6c16 into main Mar 8, 2024
7 checks passed
@YurenSUN YurenSUN deleted the yuren-testing branch March 8, 2024 00:55
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.

2 participants