[英]How to implement a data model in iOS that can handle multiple API calls?
[英]How to implement XCUITest with API Calls
我是 XCUITest 框架的新手。 我需要調用 API https://restcountries.eu/rest/v2/all獲取國家列表並顯示在 UITableView 上,因為用戶將在下一個國家/地區名稱上單擊任何基於國家/地區的標志現在工作正常我想實現 XCUITest 為此我添加了 function
[![enter image description here][1]][1]
func testTheCountryListAndAllScreen() {
app.launch()
let countryListTableView = self.app.tables["CountryList"]
XCTAssertTrue(countryListTableView.exists, "Country list have data")
let countryListCell = countryListTableView.cells
if countryListCell.count > 0 {
for cell in 0..<countryListCell.count {
let countryCell = countryListCell.element(boundBy: cell)
countryCell.tap()
self.app.buttons.staticTexts["Move to info page"].tap()
self.app.navigationBars.buttons.element(boundBy: 0).tap()
self.app.navigationBars.buttons.element(boundBy: 0).tap()
}
}
}
在 app.launch() 應用程序正在崩潰
您可以使用 URLSession 發出請求並使用 JSONEncoder 訪問數據。
如果您想測試您的表(同時更改其數據),請使用單元測試。 如果您想測試與此表的交互如何影響其他 UI 元素,請使用 UI 測試。 為了更好地了解 Xcode 中的測試,請觀看以下視頻:
您沒有提供應用程序啟動崩潰的錯誤文本,但我認為您嘗試在單元測試目標中使用 XCTest UI 測試 API。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.