如何测试可可触摸应用程序在下载文件时网络故障的情况?
我的 iOS 应用程序的功能之一是从特定服务器下载文件。当用户使用应用程序时,下载完全在后台进行。下载完成后,与该文件关联的资源将显示在应用程序屏幕上。
我的用户报告了一些有关我无法重现的丢失资源的不当行为。一些辅助信息让我怀疑问题是由于资源文件的下载中途中止引起的。然后该应用程序有一个部分下载的文件,该文件永远不会完成。
为了证实这个假设,确保任何修复都有效,并测试这种随机网络在我脚下消失的情况,我想在我的测试环境中模拟网络丢失:测试服务器是我的开发 Mac 上的网络共享,测试设备是在同一台Mac上运行的iOS模拟器。
有没有比在断点处手动关闭网络共享更方便的方法?
My iOS application, among its features, download files from a specific server. This downloading occurs entirely in the background, while the user is working on the app. When a download is complete, the resource associated with the file appears on the app screen.
My users report some misbehavior about missing resources that I could not reproduce. Some side information leads me to suspect that the problem is caused by the download of the resource's file to be aborted mid-way. Then the app has a partially downloaded file that never gets completed.
To confirm the hypothesis, to make sure any fix works, and to test for such random network vanishing under my feet, I would like to simulate the loss of the network on my test environment: the test server is web sharing on my development Mac, the test device is the iOS simulator running on the same Mac.
Is there a more convenient way to do that, than manually turning web sharing off on a breakpoint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您下载文件的方式,一种可能的选择是在下载过程中将回调委托设置为 null。它仍然会下载数据,但您的应用程序将停止接收回调。不过,我不知道如果应用程序真的断开连接,它是否会这样运行。
另一种选择是暂时将下载请求指向外部 Web 服务器上的某个随机文件,然后中途断开计算机与互联网的连接。我这样做是为了测试网络连接问题,通常可以正常工作。您的情况中有趣的问题是您是从自己的计算机下载的,因此断开连接不会有帮助。这只是为了让您可以在发生这种情况时确定应用程序内回调的顺序(它是否会进行任何回调?以什么顺序?),以便您可以在实际指向测试服务器时模拟该行为。
我想,将这两个选项结合在一起,可以获得最佳解决方案。
Depending on how you're downloading your file, one possible option would be to set the callback delegate to null halfway through the download. It would still download the data, but your application would simply stop receiving callbacks. Although, I don't know if that's how the application would function if it truly dropped the connection.
Another option would be to temporarily point the download request at some random file on an external web server, then halfway though just disconnect your computer from the internet. I've done that to test network connectivity issues and it usually works. The interesting problem in your case is that you're downloading from your own computer, so disconnecting won't help. This would just be so you can determine the order of callbacks within the application when this happens, (does it make any callbacks at all? In what order?) so that you can simulate that behavior when actually pointed to your test server.
Combine both options together, I guess, to get the best solution.