我一直在Xcode中使用新的XCUITest。 現在我正在做一個測試用例,它將執行一些特定的過程,終止應用程序並重新打開它。 我知道這在儀器中是不可能的,所以我想知道是否可以用XCUITest來做到這一點。使用XCUITest終止並重新打開應用程序iOS9
1
A
回答
0
XCUIApplication類包含可調用以關閉並重新打開應用程序的啓動和終止方法。
我不確定迅速語法,但你可以做到在Objective-C如下:
XCUIApplication *app = [[XCUIApplication alloc] init];
app.terminate;
app.launch;
3
如果您使用SWIFT和XCTestCase
import XCTest
class SomeTests: XCTestCase {
func testSomeFunctionality() {
let app = XCUIApplication()
// by setting launch arguments you can set your app to "test mode"
app.launchArguments = ["arg1", "arg2"]
app.launch()
// .... code that runs the desired procedure.
app.terminate()
// At this point you can set different launch args if you need the app to be in a different mode
app.launchArguments = ["arg1", "arg2"]
app.launch()
// .... code that finishes up the test.
}
}
相關問題
- 1. Facebook按鈕片段不打開並終止應用程序
- 2. 防止重新打開應用程序Android開發人員
- 3. 檢測應用程序重新打開?
- 4. 打開通知即使應用程序不活動或終止
- 5. Android:當應用程序重新打開時停止活動?
- 6. 程序化終止後重新打開Finder窗口
- 7. Android服務在應用程序重新打開並關閉時停止
- 8. 如何重新打開最後一個視圖,然後在iOS中終止後打開應用程序
- 9. 關閉並重新打開應用程序
- 10. Android:應用程序在關閉並重新打開後崩潰
- 11. WPF關閉應用程序並重新打開當前窗口
- 12. 關閉並重新打開Android應用程序
- 13. Word應用程序關閉並重新打開
- 14. Android應用程序關閉並重新打開時崩潰
- 15. UITextView可點擊的URL在終止應用程序後打開
- 16. 打開Safari後終止應用程序 - swift
- 17. 終止以「subprocess.Popen()」打開的應用程序?
- 18. 應用程序背景刷新ios9 swift
- 19. 使用DateTime終止應用程序?
- 20. IBM Worklight 5.x - Android應用程序意外終止並終止
- 21. 應用程序重新啓動後重新打開JTree並保存其狀態
- 22. CountDownTimer在關閉並重新打開應用程序後重新啓動
- 23. 應用程序不終止
- 24. 終止應用程序
- 25. EnterpriseLibrary.Logging終止應用程序
- 26. 應用程序終止
- 27. Android應用程序:如何關閉監聽程序並將其重新打開?
- 28. 如何防止重新打開應用程序時重置變量?
- 29. 在應用程序被終止後重新啓動Android Started Service
- 30. 在系統終止應用程序後重新啓動活動