It is kinda easy to unit test IBOutlets, but how about IBActions? I was trying to find a way how to do it, but without any luck. Is there any way to unit test connection bet
Julio Bailon's answer above translated for Swift 3:
func checkActionForButton(_ button: UIButton?, actionName: String, event: UIControlEvents = UIControlEvents.touchUpInside, target: UIViewController) -> Bool {
if let unwrappedButton = button, let actions = unwrappedButton.actions(forTarget: target, forControlEvent: event) {
var testAction = actionName
if let trimmedActionName = actionName.components(separatedBy: ":").first {
testAction = trimmedActionName
}
return (!actions.filter { $0.contains(testAction) }.isEmpty)
}
return false
}