ios – EXEC_BAD_ACCESS – When trying to access a method after storyBoard Initialisation


I am trying to write UT’s for my viewController and I am initialising my viewController in the below way :

var sut: viewController!

  override func setUp() {
    super.setUp()
    let storyboard = UIStoryboard(name: "storyBoardName", bundle: nil)
    sut = storyboard.instantiateViewController(withIdentifier: "storyboard_identifier") as? viewController
    sut.loadViewIfNeeded() // Loads the view hierarchy
  }

The story board is initialised properly non-nil with the textLabels and default connections, but when I try to access any method present inside the viewControllerClass I get a EXEC_BAD_ACCESS

func testVC() {
  XCTAssertNotNil(sut) // this passes and I can see default values for attributes being assigned
  viewController.configure() // this gives EXEC_BAD_ACCESS
}

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img