Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 723 Bytes

viewControllers.md

File metadata and controls

33 lines (21 loc) · 723 Bytes

How to test ViewControllers

import XCTest
@testable import MotionDetector

class Tests: XCTestCase {

    var viewController: ViewController!

    override func setUp() {
        viewController = viewController()
    }

    func testHiddenButton() throws {
        _ = self.viewController.view // To call viewDidLoad
        
        viewController.loadViewIfNeeded()
        
        // or 
        
        viewController.beginAppearanceTransition(true, animated: false) // viewWillAppear
        viewController.endAppearanceTransition() // viewWillDisappear
        ...
    }
}

Links that help