2017-10-10 69 views
1

我實際上是試圖在我的應用程序中使用靈活快照實現UI測試。 我正面臨一個我並不真正瞭解的問題。 我一直在環顧四周,但似乎沒有找到我的問題的答案。架構x86_64的未定義符號測試我的ViewController Swift

當我嘗試實例化我的viewcontroller以嘗試並測試與其關聯的視圖時,會發生我的問題。編譯總是失敗,並顯示此錯誤消息。

Undefined symbols for architecture x86_64: 
"__T06medici19LoginViewControllerCMa", referenced from: 
__T013mediciUITests13LoginViewTestC4specyyFyycfU_yycfU_ in 
testUILogin.o 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我的測試代碼如下所示:

import Nimble 
import Nimble_Snapshots 
import Quick 
import UIKit 

@testable import XXXXMyProject 

class LoginViewTest: QuickSpec { 

override func spec() { 

    describe("LoginView") { 
     var vcLogin: LoginViewController! 

     beforeEach { 
      let storyboard = UIStoryboard(name: "Account", bundle: nil) 
      vcLogin = storyboard.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController 
      _ = vcLogin.view // To call viewDidLoad 
     } 

     it("has a valid snapshot") { 

      expect(vcLogin.view) == recordSnapshot() 
     } 
    } 
    } 
} 

是相當新的UI測試中,我真的不明白是什麼原因造成了這個問題。 任何幫助或提示將不勝感激如何解決這個問題或改善我的UI測試代碼。

預先感謝您。

Martin

+0

檢查您的視圖控制器是否在您的測試的目標成員資格中被選中(打勾)。 –

+0

你看到這個錯誤爲鏈接錯誤嗎? –

+0

@BadhanGanesh這是否意味着我必須將我的項目的所有文件添加到我的ui測試的目標成員中?我雖然「可測試」會做到這一點,並讓我訪問我的項目的元素。 – Martin

回答

1

UI測試不能使用您的應用程序內部。要測試它,請使用單元測試,但請確保選中單元測試目標>常規中的「允許測試主機應用程序API」選項。

相關問題