Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brunomazzo/uiunittest
Run UI XCTest commands from your unit test
https://github.com/brunomazzo/uiunittest
ios swiftui ui-test uikit unit-test
Last synced: 11 days ago
JSON representation
Run UI XCTest commands from your unit test
- Host: GitHub
- URL: https://github.com/brunomazzo/uiunittest
- Owner: BrunoMazzo
- License: mit
- Created: 2023-03-05T00:36:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-22T04:59:03.000Z (6 months ago)
- Last Synced: 2024-05-22T05:35:16.979Z (6 months ago)
- Topics: ios, swiftui, ui-test, uikit, unit-test
- Language: Swift
- Homepage:
- Size: 269 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UIUnitTest
Run XCTest UI commands from your unit test.
## How it works
When you run an UI test, Apple runs two processes: the UI test process and the app process. The UI test process is the one that runs your test code and the app process is the one that runs your full app. Because these two are different process, you lose the ability to modify your app state from your test code. UIUnitTest solves this problem by running your unit test instead of the app, and running the UI test process with a server to receives commands from your unit test code and execute them.
## Installation
1. Install the package:
```swift
.package(url: "[email protected]:BrunoMazzo/UIUnitTest.git", from: "0.4.0")
```2. Add it to your Unit test target
3. Add a server start on your test scheme pre action:
3.1 Select your test target on `Provide build settings from`
3.2 Add the command:
```shell
$BUILD_DIR/../../SourcePackages/checkouts/UIUnitTest/start-server.sh
```![Pre action panel](docs/pre-action.png)
3.3 Add post action to stop the server:
```shell
$BUILD_DIR/../../SourcePackages/checkouts/UIUnitTest/stop-server.sh
```4. Start coding
## Usage
```swift
import UIUnitTest
...
@MainActor
func testExample() {
let app = App()let viewYouWantToTest = YourSwiftUIView(...) // or UIViewController
showView(viewYouWantToTest)
app.button(identifier: "some button identifier").tap()...
}
```