From 43ed5d7841b4152998fb1bf72f6c76e0db739c4c Mon Sep 17 00:00:00 2001 From: Balazs Perlaki-Horvath Date: Sun, 4 May 2025 21:55:16 +0200 Subject: [PATCH] Add UITests target --- UITests/LoadingUITest.swift | 47 +++++++++++++++++++++++++++++++ UITests/UITests-Bridging-Header.h | 4 +++ project.yml | 41 ++++++++++++++++++++++----- 3 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 UITests/LoadingUITest.swift create mode 100644 UITests/UITests-Bridging-Header.h diff --git a/UITests/LoadingUITest.swift b/UITests/LoadingUITest.swift new file mode 100644 index 00000000..6f018778 --- /dev/null +++ b/UITests/LoadingUITest.swift @@ -0,0 +1,47 @@ +// This file is part of Kiwix for iOS & macOS. +// +// Kiwix is free software; you can redistribute it and/or modify it +// under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3 of the License, or +// any later version. +// +// Kiwix is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Kiwix; If not, see https://www.gnu.org/licenses/. + +import XCTest + +final class LoadingUITest: XCTestCase { + + override func setUpWithError() throws { + // Put setup code here. This method is called before the invocation of each test method in the class. + + // In UI tests it is usually best to stop immediately when a failure occurs. + continueAfterFailure = false + + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + } + + override func tearDownWithError() throws { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() throws { + // UI tests must launch the application that they test. + let app = XCUIApplication() + app.launch() + + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testLaunchPerformance() throws { + // This measures how long it takes to launch your application. + measure(metrics: [XCTApplicationLaunchMetric()]) { + XCUIApplication().launch() + } + } +} diff --git a/UITests/UITests-Bridging-Header.h b/UITests/UITests-Bridging-Header.h new file mode 100644 index 00000000..1b2cb5d6 --- /dev/null +++ b/UITests/UITests-Bridging-Header.h @@ -0,0 +1,4 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + diff --git a/project.yml b/project.yml index b4f208a4..f47d4f36 100644 --- a/project.yml +++ b/project.yml @@ -2,8 +2,8 @@ name: Kiwix options: xcodeVersion: 16.1 deploymentTarget: # the three latest major versions should be supported - iOS: 16.6 - macOS: 13.0 + iOS: 16.6 + macOS: 13.0 generateEmptyDirectories: true useTabs: false groupSortPosition: top @@ -75,7 +75,7 @@ targetTemplates: - sdk: SystemConfiguration.framework - package: Defaults - package: StripeApplePay - sources: + sources: - path: App - path: Model - path: SwiftUI @@ -111,7 +111,7 @@ targets: INFOPLIST_KEY_UILaunchStoryboardName: SplashScreenKiwix.storyboard sources: - path: Support - excludes: + excludes: - "**/qqq.lproj" - "**/igl.lproj" - "**/dag.lproj" @@ -136,7 +136,26 @@ targets: - path: Tests dependencies: - target: Kiwix - + + UITests: + type: bundle.ui-testing + supportedDestinations: [iOS, macOS] + settings: + PRODUCT_BUNDLE_IDENTIFIER: org.kiwix.UITests + # TEST_HOST: $(BUILT_PRODUCTS_DIR)/Kiwix.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Kiwix + BUNDLE_LOADER: $(TEST_HOST) + entitlements: + path: Support/Kiwix-unitTest.entitlements + properties: + com.apple.security.app-sandbox: false + # from macOS 14, sandbox and unit test are not working together on CI + # a pop up appears that needs user acceptance + # see: https://developer.apple.com/documentation/security/accessing-files-from-the-macos-app-sandbox + sources: + - path: UITests + dependencies: + - target: Kiwix + schemes: Kiwix: build: @@ -146,8 +165,16 @@ schemes: targets: - UnitTests commandLineArguments: - testing: true + testing: true gatherCoverageData: true coverageTargets: - Kiwix - \ No newline at end of file + UITests: + build: + targets: + Kiwix: all + test: + targets: + - UITests + commandLineArguments: + testing: true