GOAL: I want to UI test my SegmentedControl - check that each segment is selected when tapped on it
CONTEXT: The shoeType UISegmentedControl has 3 segments [City, Running, Baskets]
CODE: Here is my code:
ViewController.swift :
@IBOutlet weak var shoeType: UISegmentedControl!
ViewControllerUITest.swift:
func testSegmentedControl_WhenTapped_ChangeSegment() {
app.launch()
let shoeTypeSegmentedControl = app.segmentedControls["city"]
app.segmentedControls["city"].tap()
XCTAssertEqual(shoeTypeSegmentedControl.label, "City")
}