[英]Swift - How can I identify which custom tableview cell has been modified?
[英]How can I test if a custom cell has been registered with the tableView?
如果自定義單元格已在tableView
注冊,我想進行單元測試。
-(void)viewDidLoad
{
[super viewDidLoad];
UINib *nib = [UINib nibWithNibName:@"FTStatsCellView" bundle:nil];
[[self tableView] registerNib:nib forCellReuseIdentifier:@"FTStatsCellView"];
}
單元測試:
-(void)testIfCustomCellsAreRegisteredToTable
{
[viewController viewDidLoad];
FTStatsCellView *cell = [[viewController tableView] dequeueReusableCellWithIdentifier:@"FTStatsCellView"];
XCTAssertNotNil(cell, @"Custom cell FTStatsCellView is not registered with the table.");
}
測試失敗並顯示以下消息:
[FTStatsViewControllerTests testIfCustomCellsAreRegisteredToTable]失敗:無法在bundle中加載NIB:'NSBundle(loaded)',名稱為'FTStatsCellView'
有什么建議? 謝謝
更新
如果我單擊項目並將test target
的目標從None更改為應用程序,那么它可以正常工作。
但這有副作用,每次我想運行單元測試時應用程序在模擬器中運行。
有什么建議?
設置Target為測試目標指定BUNDLE_LOADER和TEST_HOST。 運行單元測試時,這對於以下順序是必需的:
所有這些對於在Cocoa Touch之上運行的單元測試是必要的 - 特別是涉及視圖控制器加載其視圖層次結構的任何事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.