我正在为项目添加单元测试,并且在如何为UITableViewCell自定义类编写测试方面遇到了麻烦。这是该类的代码:
class ConfirmSubmitTableViewCell: UITableViewCell, UICollectionViewDelegate {
var reportECTag: ReportECTag!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
let photoArray = Utility.sharedInstance.getPhotoArray(reportECTag.fieldDataInformationDict)
return (photoArray.count)
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let collectionCell = collectionView.dequeueReusableCellWithReuseIdentifier(kCollectionViewCell, forIndexPath: indexPath)
let imageView: UIImageView = collectionCell.viewWithTag(287) as! UIImageView
let photoArray = Utility.sharedInstance.getPhotoArray(reportECTag.fieldDataInformationDict)
imageView.image = UIImage(data: (photoArray.objectAtIndex(indexPath.row) as? NSData)!)//photoArray.objectAtIndex(indexPath.row) as? UIImage
return collectionCell
}
例如,我如何测试awakeFromNib()和setSelected?
谢谢。