Skip to content

[Technical Questions] How to write tests for codes executed only after getting HealthKit Data #68

Discussion options

You must be logged in to vote

Hi @YurenSUN, a great question!

You can manually create a lot of the HealthKit data types and manually call the functions you want to call within a unit test.
E.g., you can create a simple HKSample like this: https://developer.apple.com/documentation/healthkit/hkquantitysample/1615016-init.

For those that you cannot create using code or when you need to do a full integration test: We have a dedicated packe for this: https://github.com/StanfordBDHG/XCTHealthKit. It allows you to run UI tested that add elements from the health app.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@YurenSUN
Comment options

YurenSUN Feb 21, 2024
Collaborator Author

Answer selected by YurenSUN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants