Skip to content

Commit

Permalink
feat(apple): support preferredScreenCaptureFormat (MarathonLabs#965)
Browse files Browse the repository at this point in the history
* feat(apple): support preferredScreenCaptureFormat
  • Loading branch information
Malinskiy authored Aug 8, 2024
1 parent 27b3099 commit 4107a4e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ data class XcresultConfiguration(
@JsonProperty("pullingPolicy") val pullingPolicy: PullingPolicy = PullingPolicy.ALWAYS,
@JsonProperty("remoteClean") val remoteClean: Boolean = true,
@JsonProperty("attachments") val attachments: AttachmentsConfiguration = AttachmentsConfiguration(),
@JsonProperty("preferredScreenCaptureFormat") val preferredScreenCaptureFormat: ScreenCaptureFormat? = null,
)

data class AttachmentsConfiguration(
Expand Down Expand Up @@ -36,3 +37,13 @@ enum class PullingPolicy {
@JsonProperty("ALWAYS") ALWAYS,
@JsonProperty("ON_FAILURE") ON_FAILURE,
}

enum class ScreenCaptureFormat {
@JsonProperty("SCREENSHOTS") SCREENSHOTS,
@JsonProperty("SCREEN_RECORDING") SCREEN_RECORDING;

fun xcodevalue() = when(this) {
SCREENSHOTS -> "screenshots"
SCREEN_RECORDING -> "screenRecording"
}
}
15 changes: 15 additions & 0 deletions docs/runner/apple/configure/ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,21 @@ deleted on success and user attachments will always be kept in the xcresult, but

Possible values for the lifetime are `KEEP_ALWAYS`, `DELETE_ON_SUCCESS` and `KEEP_NEVER`.

#### xcresult screen recorder configuration
Since Xcode 15 test execution defaults to recording test video and attaching it to xcresults. This can be configured as follows:
```yaml
xcresult:
preferredScreenCaptureFormat: SCREENSHOTS
```

Possible values for the screen capture format are `SCREENSHOTS` and `SCREEN_RECORDING`.

:::warning

This setting doesn't influence marathon's screen recorder which is configured separately.

:::

### Screen recorder configuration

By default, marathon will record a h264-encoded video of the internal display with black mask if it is supported.
Expand Down
15 changes: 15 additions & 0 deletions docs/runner/apple/configure/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,21 @@ deleted on success and user attachments will always be kept in the xcresult, but

Possible values for the lifetime are `KEEP_ALWAYS`, `DELETE_ON_SUCCESS` and `KEEP_NEVER`.

#### xcresult screen recorder configuration
Since Xcode 15 test execution defaults to recording test video and attaching it to xcresults. This can be configured as follows:
```yaml
xcresult:
preferredScreenCaptureFormat: SCREENSHOTS
```

Possible values for the screen capture format are `SCREENSHOTS` and `SCREEN_RECORDING`.

:::warning

This setting doesn't influence marathon's screen recorder which is configured separately.

:::

### xctestrun Environment and TestingEnvironment variables

You can specify additional Environment and TestingEnvironment variables for your test run:
Expand Down
5 changes: 4 additions & 1 deletion sample/ios-app/Marathonfile-uiTests
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ vendorConfiguration:
username: malinskiy
key: ${HOME}/.ssh/marathon
knownHostsPath: ${HOME}/.ssh/known_hosts
# Temporary fix for https://github.com/hierynomus/sshj/pull/934
keepAliveInterval: "PT0H0M0S"
xcresult:
pullingStrategy: ALWAYS
pullingPolicy: ALWAYS
remoteClean: true
preferredScreenCaptureFormat: SCREENSHOTS
lifecycle:
onPrepare: []
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class TestRootFactory(
testBundlePath = remoteXctest,
testHostPath = testRunnerApp,
uiTargetAppPath = remoteTestApp,
preferredScreenCaptureFormat = xcresultConfiguration.preferredScreenCaptureFormat?.xcodevalue(),
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TestTarget : TestTarget {
testRegion: String? = null,
isUITestBundle: Boolean? = null,
isAppHostedTestBundle: Boolean? = null,
preferredScreenCaptureFormat: String? = null,
): V2TestTarget {
return V2TestTarget(
name = name,
Expand Down Expand Up @@ -65,6 +66,7 @@ class TestTarget : TestTarget {
testRegion = testRegion,
isUITestBundle = isUITestBundle,
isAppHostedTestBundle = isAppHostedTestBundle,
preferredScreenCaptureFormat = preferredScreenCaptureFormat,
)
}

Expand Down Expand Up @@ -161,6 +163,7 @@ class TestTarget : TestTarget {
testRegion: String? = null,
isUITestBundle: Boolean? = null,
isAppHostedTestBundle: Boolean? = null,
preferredScreenCaptureFormat: String? = null,
) : super(
testBundlePath,
testHostPath,
Expand Down Expand Up @@ -192,6 +195,7 @@ class TestTarget : TestTarget {
testRegion?.let { this.testRegion = it }
isUITestBundle?.let { this.isUITestBundle = it }
isAppHostedTestBundle?.let { this.isAppHostedTestBundle = it }
preferredScreenCaptureFormat?.let { this.preferredScreenCaptureFormat = it }
}

/**
Expand Down Expand Up @@ -270,4 +274,10 @@ class TestTarget : TestTarget {
*/
var isUITestBundle: Boolean? by delegate.optionalDelegateFor("IsUITestBundle")
var isAppHostedTestBundle: Boolean? by delegate.optionalDelegateFor("IsAppHostedTestBundle")

/**
* Added in xcode 15, possible values are [screenshots, screenRecording]. Defaults to screenRecording
* Ignored by previous versions of xcode
*/
var preferredScreenCaptureFormat: String? by delegate.optionalDelegateFor("preferredScreenCaptureFormat")
}

0 comments on commit 4107a4e

Please sign in to comment.