Skip to content

Commit c8dc833

Browse files
committed
refactor(DemoTests): lazy var
1 parent 39f2e6d commit c8dc833

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

DemoTests/DemoTests.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import XCTest
22
@testable import Demo
33

44
class DemoTests: XCTestCase {
5-
var viewController: ViewController!
5+
lazy var viewController: ViewController = {
6+
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
7+
let id = String(describing: ViewController.self)
8+
9+
let viewController = storyboard.instantiateViewController(withIdentifier: id) as! ViewController
10+
return viewController
11+
}()
612

713
override func setUp() {
814
super.setUp()
915

10-
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
11-
let id = String(describing: ViewController.self)
12-
13-
viewController = storyboard.instantiateViewController(withIdentifier: id) as! ViewController
1416
viewController.viewDidLoad()
1517
}
1618

0 commit comments

Comments
 (0)