Skip to content

Commit

Permalink
try to fix locale issues (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaskollmer authored Jan 23, 2025
1 parent 5b6bebe commit e3e319e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import XCTHealthKit

class HealthKitUITests: XCTestCase {
func testAddMockData() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSample(healthApp: healthApp, .steps(value: 71))
try launchAndAddSample(healthApp: healthApp, .electrocardiogram())
}
Expand All @@ -50,7 +50,7 @@ import XCTHealthKit

class HealthKitUITests: XCTestCase {
func testAddMockData() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSamples(healthApp: healthApp, [
.activeEnergy(),
.electrocardiogram(),
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCTHealthKit/XCTHealthKit.docc/XCTHealthKit.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import XCTHealthKit

class HealthKitUITests: XCTestCase {
func testAddMockData() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSample(healthApp: healthApp, .steps(value: 71))
try launchAndAddSample(healthApp: healthApp, .electrocardiogram())
}
Expand All @@ -43,7 +43,7 @@ import XCTHealthKit

class HealthKitUITests: XCTestCase {
func testAddMockData() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSamples(healthApp: healthApp, [
.activeEnergy(),
.electrocardiogram(),
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCTHealthKit/XCTHealthKitAddSampleInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ extension NewHealthSampleInput {
}

/// Creates a new Electrocardiogram sample input, with the specified values
public static func electrocardiogram(date: DateComponents? = nil) -> Self {
.init(sampleType: .electrocardiograms, date: date, enterSampleValueHandler: .custom { _, app in
public static func electrocardiogram() -> Self {
.init(sampleType: .electrocardiograms, date: nil, enterSampleValueHandler: .custom { _, app in
XCTAssert(app.tables.staticTexts["High Heart Rate"].firstMatch.waitForExistence(timeout: 2))
app.tables.staticTexts["High Heart Rate"].firstMatch.tap()
})
Expand Down
7 changes: 2 additions & 5 deletions Sources/XCTHealthKit/XCTest+HealthKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ struct XCTHealthKitError: Error {

extension XCUIApplication {
/// The Apple Health app
public static func healthApp(locale: Locale = .current) -> XCUIApplication {
let app = XCUIApplication(bundleIdentifier: "com.apple.Health")
app.launchArguments.append("-AppleLocale")
app.launchArguments.append(locale.identifier)
return app
public static var healthApp: XCUIApplication {
XCUIApplication(bundleIdentifier: "com.apple.Health")
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/UITests/TestAppUITests/TestAppUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestAppUITests: XCTestCase {

@MainActor
func testXCTHealthKitAddSamples1() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSample(healthApp: healthApp, .electrocardiogram())
try launchAndAddSample(healthApp: healthApp, .steps())
healthApp.terminate()
Expand All @@ -35,7 +35,7 @@ class TestAppUITests: XCTestCase {

@MainActor
func testXCTHealthKitAddSamples2() throws {
let healthApp = XCUIApplication.healthApp()
let healthApp = XCUIApplication.healthApp
try launchAndAddSamples(healthApp: healthApp, [.electrocardiogram(), .steps()])
healthApp.terminate()
try launchAndAddSamples(healthApp: healthApp, [.pushes(), .restingHeartRate()])
Expand All @@ -46,7 +46,7 @@ class TestAppUITests: XCTestCase {

@MainActor
func testSampleEntryWithDateAndTime() throws {
try launchAndAddSample(healthApp: .healthApp(), .steps(
try launchAndAddSample(healthApp: .healthApp, .steps(
value: 52,
date: DateComponents(year: 2025, month: 01, day: 19, hour: 14, minute: 42)
))
Expand Down

0 comments on commit e3e319e

Please sign in to comment.