我正在为iOS应用程序编写UI测试。我想从本地json文件读取数据。阅读XCUITest中的本地JSON文件
我用下面的代码获取的路径,我的JSON文件: Reading in a JSON File Using Swift:
func testExample() {
readJSON()
}
func readJSON(){
let bundle = Bundle(for:myTestClass.self)
if let path = bundle.url(forResource: "myurl", withExtension: "json"){
print("Got the path")
print(path)
}
else{
print("Invalid filename/path")
}
我曾尝试使用以下计算器问题的解决尝试。没有工作!
另外,我看了一下下面的Apple文档: https://developer.apple.com/swift/blog/?id=37
任何帮助将不胜感激!
被存储在本地目录中的JSON或它重视的Xcode? – KrishnaCA