Sobes.tech
Junior — Senior

Code execution check in viewDidLoad()

livecode

Task condition

It is necessary to write a unit test that guarantees that when the viewDidLoad() method is called on an instance of ViewController, the track method of the analytics object is called with the argument "viewController loaded".

class ViewController {
    lazy var analytics: AnalyticsProtocol = Analytics.shared

    func viewDidLoad() {
        analytics.track("viewController loaded")
    }
}