Skip to content

Instantly share code, notes, and snippets.

@randycoulman
Last active March 5, 2016 21:49
Show Gist options
  • Save randycoulman/671cfc0f1d21bf681199 to your computer and use it in GitHub Desktop.
Save randycoulman/671cfc0f1d21bf681199 to your computer and use it in GitHub Desktop.
Base class for view controller tests in Swift
@testable import MyApp
import UIKit
import XCTest
class ViewControllerTests: XCTestCase {
var storyboard: UIStoryboard!
func storyboardName() -> String {
return "Main"
}
override func setUp() {
super.setUp()
storyboard = UIStoryboard(name: storyboardName(), bundle: nil)
}
func viewControllerWithIdentifier<T>(identifier: String) -> T {
return storyboard.instantiateViewControllerWithIdentifier(identifier) as! T
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment