You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+11-32
Original file line number
Diff line number
Diff line change
@@ -81,43 +81,22 @@ Do you want to try the latest version in development of Nextcloud iOS ? Simple,
81
81
There are currently no preresquites for unit testing that need to be done. Mock everything that's not needed.
82
82
83
83
### Integration tests:
84
-
To run integration tests, we need a docker instance of a Nextcloud test server.
85
-
The CI does all this automatically, but to do it manually:
86
-
1. Run `docker run --rm -d -p 8080:80 ghcr.io/juliushaertl/nextcloud-dev-php80:latest` to spin up a docker container of the Nextcloud test server.
87
-
2. Log in on the test server and generate an app password for device. There are a couple test accounts, but `admin` as username and password works best.
88
-
3. Build the iOS project once. This will generate an `.env-vars` file in the root directory. It contains env vars that the project will use for testing.
89
-
4. Provide proper values for the env vars inside the file. Here is an example:
5. Build the iOS project again. If all the values are set correctly you will see a generated file called `EnvVars.generated.swift`. It contains the env vars as Swift fields that can be easily used in code:
84
+
To run integration tests, you need a docker instance of a Nextcloud test server. [This](https://github.com/szaimen/nextcloud-easy-test) is a good start.
85
+
86
+
1. In `TestConstants.swift` you must specify your instance credentials. App Token is automatically generated.
87
+
96
88
```
97
-
/**
98
-
This is generated from the .env-vars file in the root directory. If there is an environment variable here that is needed and not filled, please look into this file.
99
-
*/
100
-
public struct EnvVars {
101
-
static let testUser = "nextcloud"
102
-
static let testPassword = "FAeSR-6Jk7s-DzLny-CCQHL-f49BP"
103
-
static let testServerUrl = "http://localhost:8080"
89
+
public class TestConstants {
90
+
static let timeoutLong: Double = 400
91
+
static let server = "http://localhost:8080"
92
+
static let username = "admin"
93
+
static let password = "admin"
94
+
static let account = "\(username) \(server)"
104
95
}
105
96
```
106
-
6. You can now run the integration tests. They will use the env vars to connect to the test server to do the testing.
107
97
98
+
2. Run the integration tests.
108
99
109
100
### UI tests
110
101
111
102
UI tests also use the docker server, but besides that there is nothing else you need to do.
112
-
113
-
### Snapshot tests
114
-
115
-
Snapshot tests are made via this library: https://github.com/pointfreeco/swift-snapshot-testing and these 2 extensions:
116
-
1.https://github.com/doordash-oss/swiftui-preview-snapshots - for creating SwiftUI snapshot tests via previews.
117
-
2.https://github.com/alexey1312/SnapshotTestingHEIC - makes snapshot images HEIC instead of PNGs for much reduced size.
118
-
119
-
Snapshot tests are a great way to test if UI elements are consistent with designs and don't break with new commits, but they can be very finicky and the smallest change can cause them to fail. Keep in mind:
120
-
121
-
- For SwiftUI snapshot tests, It's always a good idea to utilize previews, as they do not depend on device/app state and it has less chances to fail due to wrong state.
122
-
123
-
- For UIKit snapshot tests, try to include mock dependencies to always make sure the UI is rendered the same way. Even a text change can cause the tests to fail.
0 commit comments