In ViewControllerTests set dataSource or delegate nil immediately before calling method under test viewDidLoad to make sure we are testing effect of viewDidLoad.