Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
The testing strategy for VoiceInk combines developer-led testing as part of the contribution process, foundational unit and UI test targets, and in-app performance analysis features that provide diagnostic data. The current implementation relies on guidelines for contributors to ensure code quality, with formal automated testing frameworks in place but not yet extensively utilized.
The project's documentation emphasizes a proactive approach to quality, requiring contributors to run and add tests for new functionality. This is supplemented by diagnostic tools that help in debugging and user-facing metrics that provide insights into the application's performance.
Contribution and Development Testing
The project outlines a clear testing process for developers contributing to the codebase. This process is documented in CONTRIBUTING.md and BUILDING.md and is a prerequisite for submitting pull requests.
The core requirements for contributors include:
- Running all existing tests to ensure no regressions are introduced.
- Adding new tests for any new features or functionality.
- Ensuring all tests pass before submitting a pull request.
Sources: CONTRIBUTING.md:52-55, BUILDING.md:38-40
The following diagram illustrates the testing workflow for contributors.
Sources: CONTRIBUTING.md:43-55
Automated Testing Framework
The project includes standard Xcode testing targets for unit and UI tests, although the test suites themselves are currently minimal and appear to be based on default templates.
Unit Testing
The VoiceInkTests target contains the unit tests for the application. The primary test file, VoiceInkTests.swift, includes a placeholder test case.
- File:
VoiceInkTests/VoiceInkTests.swift - Structure: A
structnamedVoiceInkTestswith a single example test methodexample(). - Purpose: This target is intended for testing the application's logic, data models, and services in isolation.
// VoiceInkTests/VoiceInkTests.swift:11-15
struct VoiceInkTests {
@Test func example() async throws {
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
}
}
Sources: VoiceInkTests/VoiceInkTests.swift:11-15
UI Testing
The project has two UI test targets: VoiceInkUITests and VoiceInkUITestsLaunchTests. These are used to verify the application's user interface and user flows.
General UI Tests
The VoiceInkUITests class provides a standard structure for UI testing.
- File:
VoiceInkUITests/VoiceInkUITests.swift - Class:
VoiceInkUITests - Methods:
setUpWithError(): Prepares the test environment. ThecontinueAfterFailureflag is set tofalse, meaning tests stop at the first failure.tearDownWithError(): Cleans up after each test.testExample(): A placeholder UI test that launches the application.
Sources: VoiceInkUITests/VoiceInkUITests.swift:10-31
Launch Performance Tests
A dedicated test, VoiceInkUITestsLaunchTests, measures the application's launch performance.
- File:
VoiceInkUITests/VoiceInkUITestsLaunchTests.swift - Class:
VoiceInkUITestsLaunchTests - Method:
testLaunch()- This test uses the
measurefunction withXCTApplicationLaunchMetricto record the time it takes for the application to launch. - It also captures a screenshot of the launch screen and attaches it to the test results for verification.
- This test uses the
// VoiceInkUITests/VoiceInkUITests.swift:34-41
@MainActor
func testLaunchPerformance() throws {
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
// This measures how long it takes to launch your application.
measure(metrics: [XCTApplicationLaunchMetric()]) {
XCUIApplication().launch()
}
}
}
Sources: VoiceInkUITests/VoiceInkUITests.swift:34-41
The following diagram shows the relationship between the UI test classes.
In-App Performance and Diagnostics
VoiceInk includes built-in views for performance analysis and a service for collecting system information, which serve as important tools for quality assurance and debugging.
Performance Analysis
The PerformanceAnalysisView provides a detailed breakdown of transcription and enhancement performance based on historical data. This allows for empirical testing of different AI models and system configurations.
The analysis logic is contained within the analyze static method, which processes an array of Transcription objects.
The data flow for this analysis is as follows:
The view calculates and displays several key metrics for both transcription and enhancement models.
| Metric | Description | Source File |
|---|---|---|
| Total Transcripts | The total number of transcription records. | PerformanceAnalysisView.swift:103 |
| Analyzable | The count of transcripts that have transcription duration data. | PerformanceAnalysisView.swift:104 |
| Enhanced | The count of transcripts that have been processed by an AI enhancement model. | PerformanceAnalysisView.swift:106 |
| Avg. Processing Time | The average time taken to process a file for a specific model. | PerformanceAnalysisView.swift:142 |
| Speed Factor (RTFX) | Real-Time Factor: how much faster the transcription is than the audio's duration. Calculated as totalAudioDuration / totalProcessingTime. | PerformanceAnalysisView.swift:148-150 |
Sources: [VoiceInk/Views/Metrics/PerformanceAnalysisView.swift]
User Metrics Dashboard
The MetricsContent view provides a high-level dashboard of user activity and savings, which also serves as a form of real-world usage testing.
| Metric | Description | Source File |
|---|---|---|
| Time Saved | Estimated time saved by using VoiceInk compared to average typing speed (35 WPM). | MetricsContent.swift:191-196 |
| Sessions Recorded | Total number of transcription sessions. | MetricsContent.swift:100 |
| Words Dictated | Total number of words transcribed. | MetricsContent.swift:107, MetricsContent.swift:183-184 |
| Words Per Minute | The user's average dictation speed. | MetricsContent.swift:114, MetricsContent.swift:198-201 |
| Keystrokes Saved | An estimation of keystrokes saved, assuming an average of 5 characters per word. | MetricsContent.swift:124, MetricsContent.swift:203-205 |
Sources: [VoiceInk/Views/Metrics/MetricsContent.swift]
System Information Service
For debugging and issue reporting, the SystemInfoService collects a comprehensive set of data about the user's hardware, software, and application configuration. This is crucial for reproducing and diagnosing bugs reported by users.
The service can be triggered from the MetricsContent view via a "Copy System Info" button.
Sources: VoiceInk/Views/Metrics/MetricsContent.swift:140-143, VoiceInk/Services/SystemInfoService.swift:38-42
The collected information includes:
| Category | Details | Source File |
|---|---|---|
| App Information | App Version, Build Version, License Status. | SystemInfoService.swift:15-17, SystemInfoService.swift:48-54, SystemInfoService.swift:162-171 |
| Operating System | macOS Version. | SystemInfoService.swift:20 |
| Hardware | Device Model, CPU, Memory, Architecture. | SystemInfoService.swift:23-26, SystemInfoService.swift:56-83 |
| Audio Settings | Input Mode, Current Device, Available Devices. | SystemInfoService.swift:29-31, SystemInfoService.swift:85-110 |
| Hotkey Settings | Primary and Secondary Hotkeys. | SystemInfoService.swift:34-35, SystemInfoService.swift:112-126 |
| Transcription | Selected Model, Language, AI Enhancement Status, Provider, and Model. | SystemInfoService.swift:38-42, SystemInfoService.swift:128-151 |
| Permissions | Status for Accessibility, Screen Recording, and Microphone. | SystemInfoService.swift:45-47, SystemInfoService.swift:152-160 |
Sources: [VoiceInk/Services/SystemInfoService.swift]
Summary
The testing strategy for VoiceInk is multifaceted, blending developer discipline with automated tools and in-app diagnostics. While the formal unit and UI test suites are currently in a foundational state, the project's contribution guidelines mandate that developers are responsible for testing their own changes. This is strongly supported by a robust performance analysis feature that allows for empirical validation of transcription models and a comprehensive system information service that accelerates bug diagnosis and resolution. This approach prioritizes real-world performance and stability, especially in the context of a complex system involving multiple AI models and hardware configurations.