简体   繁体   中英

Automated Unit Test on Healthkit permission

I am writing a react-native bridge for healthkit that includes the initialization of Healthkit. I also need to write an unit test for the modules.

I would like to use Travis to auto test on the project. Therefore, I need a automatic way that can press on the Allow button. Otherwise, the permission UI will block the unit testing process.

So, I need to know how automatically press on the allow button.

在此处输入图片说明

I was able to reach those buttons with:

lazy var turnOnAllCategories = app.tables.cells.firstMatch
lazy var allowCategoriesConnectionButton = app.navigationBars.buttons.element(boundBy: 1)

On my test I check if the popup form is displayed with:

if turnOnAllCategories.waitForExistence(timeout: waitForExistenceTimeFrame) {
    turnOnAllCategories.tap()
    allowCategoriesConnectionButton.tap()
 }

Keep in mind that base on your UI, maybe you will need to filter a bit more the results of app.tables and app.navigationBars.buttons

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM