diff --git a/peekaboo-cli/Tests/peekabooTests/ApplicationFinderTests.swift b/peekaboo-cli/Tests/peekabooTests/ApplicationFinderTests.swift index e406a60..6f82554 100644 --- a/peekaboo-cli/Tests/peekabooTests/ApplicationFinderTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/ApplicationFinderTests.swift @@ -96,10 +96,7 @@ struct ApplicationFinderTests { for app in apps { #expect(!app.app_name.isEmpty) - // Some system processes may have empty bundle IDs - if !app.bundle_id.isEmpty { - #expect(!app.bundle_id.isEmpty) - } + // Some system processes may have empty bundle IDs - no need to check twice #expect(app.pid > 0) #expect(app.window_count >= 0) } @@ -118,8 +115,8 @@ struct ApplicationFinderTests { #expect(result.localizedName != nil) #expect(!result.localizedName!.isEmpty) } catch { - // Expected if app is not installed - #expect(Bool(true)) + // Expected if app is not installed - no assertion needed + continue } } } @@ -379,27 +376,18 @@ struct ApplicationFinderEdgeCaseTests { } @Test("Fuzzy matching finds similar apps", .tags(.fast)) - func fuzzyMatchingFindsSimilarApps() { + func fuzzyMatchingFindsSimilarApps() throws { // Test that fuzzy matching can find apps with typos - do { - let result = try ApplicationFinder.findApplication(identifier: "Finderr") - // Should find "Finder" despite the typo - #expect(result.localizedName?.lowercased().contains("finder") == true) - } catch { - Issue.record("Fuzzy matching should have found Finder for 'Finderr', got error: \(error)") - } + let result = try ApplicationFinder.findApplication(identifier: "Finderr") + // Should find "Finder" despite the typo + #expect(result.localizedName?.lowercased().contains("finder") == true) } @Test("Non-existent app throws error", .tags(.fast)) func nonExistentAppThrowsError() { // Test with a completely non-existent app name - do { + #expect(throws: ApplicationError.notFound("XyzNonExistentApp123")) { _ = try ApplicationFinder.findApplication(identifier: "XyzNonExistentApp123") - Issue.record("Expected error for non-existent app 'XyzNonExistentApp123'") - } catch let ApplicationError.notFound(identifier) { - #expect(identifier == "XyzNonExistentApp123") - } catch { - Issue.record("Expected ApplicationError.notFound, got \(error)") } } diff --git a/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift b/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift index 4b1e66e..005a41d 100644 --- a/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/PermissionsCheckerTests.swift @@ -11,9 +11,9 @@ struct PermissionsCheckerTests { // Test screen recording permission check let hasPermission = PermissionsChecker.checkScreenRecordingPermission() - // This test will pass or fail based on actual system permissions - // The result should be a valid boolean - #expect(hasPermission == true || hasPermission == false) + // Just verify we got a valid boolean result (the API works) + // The actual value depends on system permissions + _ = hasPermission } @Test("Screen recording permission check is consistent", .tags(.fast)) @@ -28,8 +28,8 @@ struct PermissionsCheckerTests { @Test("Screen recording permission check performance", arguments: 1...5) func screenRecordingPermissionPerformance(iteration: Int) { // Permission checks should be fast - let hasPermission = PermissionsChecker.checkScreenRecordingPermission() - #expect(hasPermission == true || hasPermission == false) + _ = PermissionsChecker.checkScreenRecordingPermission() + // Performance is measured by the test framework's execution time } // MARK: - Accessibility Permission Tests @@ -39,8 +39,9 @@ struct PermissionsCheckerTests { // Test accessibility permission check let hasPermission = PermissionsChecker.checkAccessibilityPermission() - // This will return the actual system state - #expect(hasPermission == true || hasPermission == false) + // Just verify we got a valid boolean result (the API works) + // The actual value depends on system permissions + _ = hasPermission } @Test("Accessibility permission matches AXIsProcessTrusted", .tags(.fast)) diff --git a/peekaboo-cli/Tests/peekabooTests/WindowManagerTests.swift b/peekaboo-cli/Tests/peekabooTests/WindowManagerTests.swift index a828f52..7d7a820 100644 --- a/peekaboo-cli/Tests/peekabooTests/WindowManagerTests.swift +++ b/peekaboo-cli/Tests/peekabooTests/WindowManagerTests.swift @@ -210,7 +210,8 @@ struct WindowManagerAdvancedTests { let apps = NSWorkspace.shared.runningApplications guard let app = apps.first(where: { $0.bundleIdentifier == bundleId }) else { - return // Skip test if app not running + // Use Swift Testing's conditional execution instead of return + throw XCTSkip("App with bundle ID \(bundleId) is not running") } let windows = try WindowManager.getWindowsForApp(pid: app.processIdentifier)