## やりたいこと
UITestを実行したいが、Failed to get matching
となってしまう。
## 試したこと
現在2つのテストを実行しようとしていますが、両方に
Failed to get matching snapshots: Application com.example.kazuki.CodeCheck-Test-Yumemi-2 is not running
が出てしまいます。
解決策を教えて頂きたいです。
(ビルドは成功します。)
swift
1 let app = XCUIApplication() 2 var repo: [[String: Any]] = [] 3 4 func testChecked() { 5 /// app配下のcellで指定したAccessibility IDに合致するものを全て取得する 6 let cells = self.app.cells.matching(identifier: "TestCell") 7 /// 取得できたセルの数の検査 8 XCTAssertEqual(cells.count, repo.count) // Failed to get matching snapshots: Application com.example.kazuki.CodeCheck-Test-Yumemi-2 is not running 9 } 10 11 func testTitleisEnabled() { 12 let label = XCUIApplication().staticTexts["RepositoryTitle"] 13 XCTAssertTrue(label.isEnabled) // Failed to get matching snapshots: Application com.example.kazuki.CodeCheck-Test-Yumemi-2 is not running 14 }
## エラー
swift
1Failed to get matching snapshot: Application com.example.kazuki.CodeCheck-Test-Yumemi-2 is not running
UITests全体コード
import XCTest class CodeCheck_Test_Yumemi_2UITests: XCTestCase { let app = XCUIApplication() var repo: [[String: Any]] = [] func testChecked() { /// app配下のcellで指定したAccessibility IDに合致するものを全て取得する let cells = self.app.cells.matching(identifier: "TestCell") /// 取得できたセルの数の検査 XCTAssertEqual(cells.count, repo.count) } func testTitleisEnabled() { let label = XCUIApplication().staticTexts["RepositoryTitle"] XCTAssertTrue(label.isEnabled) } override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. // In UI tests it is usually best to stop immediately when a failure occurs. continueAfterFailure = false // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. } override func tearDownWithError() throws { // Put teardown code here. This method is called after the invocation of each test method in the class. } func testExample() throws { // UI tests must launch the application that they test. let app = XCUIApplication() app.launch() // Use recording to get started writing UI tests. // Use XCTAssert and related functions to verify your tests produce the correct results. } func testLaunchPerformance() throws { if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { // This measures how long it takes to launch your application. measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { XCUIApplication().launch() } } } }
質問は以上です。
お時間あるときに、ご返信頂けましたら幸いです????
あなたの回答
tips
プレビュー