33# Integration tests for Sentry Unity SDK
44#
55# Environment variables:
6- # SENTRY_TEST_PLATFORM: target platform (Android, Desktop, iOS, WebGL)
7- # SENTRY_TEST_DSN : test DSN
6+ # SENTRY_TEST_PLATFORM: target platform (Android, Desktop, iOS, WebGL, Xbox )
7+ # SENTRY_DSN : test DSN
88# SENTRY_AUTH_TOKEN: authentication token for Sentry API
99#
10- # SENTRY_TEST_APP: path to the test app (APK, executable, .app bundle, or WebGL build directory)
10+ # SENTRY_TEST_APP: path to the test app (APK, executable, .app bundle, WebGL build directory,
11+ # or Xbox packaged build directory containing a .xvc)
1112#
1213# Platform-specific environment variables:
1314# iOS: SENTRY_IOS_VERSION - iOS simulator version (e.g. "17.0" or "latest")
15+ # Xbox: XBCONNECT_TARGET - Xbox devkit IP address
1416
1517Set-StrictMode - Version latest
1618$ErrorActionPreference = " Stop"
@@ -30,9 +32,45 @@ BeforeAll {
3032 " Android" { return @ (" -e" , " test" , $Action ) }
3133 " Desktop" { return @ (" --test" , $Action , " -logFile" , " -" ) }
3234 " iOS" { return @ (" --test" , $Action ) }
35+ " Xbox" { return @ (" --test" , $Action ) }
3336 }
3437 }
3538
39+ # Retrieve the integration test log file from Xbox and attach it to the run result.
40+ # The Unity app writes to D:\Logs\UnityIntegrationTest.log on Xbox (UNITY_GAMECORE).
41+ function Get-XboxLogOutput {
42+ param (
43+ [Parameter (Mandatory = $true )]
44+ $RunResult ,
45+
46+ [Parameter (Mandatory = $true )]
47+ [string ]$Action
48+ )
49+
50+ $logFileName = " UnityIntegrationTest.log"
51+ $logLocalDir = " $PSScriptRoot /results/xbox-logs/$Action "
52+ New-Item - ItemType Directory - Path $logLocalDir - Force | Out-Null
53+
54+ try {
55+ Copy-DeviceItem - DevicePath " D:\Logs\$logFileName " - Destination $logLocalDir
56+ } catch {
57+ throw " Failed to retrieve Xbox log file (D:\Logs\$logFileName ): $_ "
58+ }
59+
60+ $localFile = Join-Path $logLocalDir $logFileName
61+ $logContent = Get-Content $localFile - ErrorAction SilentlyContinue
62+ if (-not $logContent -or $logContent.Count -eq 0 ) {
63+ $localFiles = Get-ChildItem - Path $logLocalDir - ErrorAction SilentlyContinue
64+ $localContents = if ($localFiles ) { ($localFiles | ForEach-Object { $_.Name }) -join " , " } else { " (empty — D:\Logs\ likely did not exist on device)" }
65+ throw " Xbox log file was empty or missing (D:\Logs\$logFileName ). Copied directory contains: $localContents "
66+ }
67+
68+ Write-Host " Retrieved log file from Xbox ($ ( $logContent.Count ) lines)" - ForegroundColor Green
69+
70+ $RunResult.Output = $logContent
71+ return $RunResult
72+ }
73+
3674 # Run a WebGL test action via headless Chrome
3775 function Invoke-WebGLTestAction {
3876 param (
@@ -110,6 +148,12 @@ BeforeAll {
110148 $appArgs = Get-AppArguments - Action $Action
111149 $runResult = Invoke-DeviceApp - ExecutablePath $script :ExecutablePath - Arguments $appArgs
112150
151+ # On Xbox, console output is not available in non-development builds.
152+ # Retrieve the log file the app writes directly to disk.
153+ if ($script :Platform -eq " Xbox" ) {
154+ $runResult = Get-XboxLogOutput - RunResult $runResult - Action $Action
155+ }
156+
113157 # Save result to JSON file
114158 $runResult | ConvertTo-Json - Depth 5 | Out-File - FilePath (Get-OutputFilePath " ${Action} -result.json" )
115159
@@ -120,6 +164,10 @@ BeforeAll {
120164 $sendArgs = Get-AppArguments - Action " crash-send"
121165 $sendResult = Invoke-DeviceApp - ExecutablePath $script :ExecutablePath - Arguments $sendArgs
122166
167+ if ($script :Platform -eq " Xbox" ) {
168+ $sendResult = Get-XboxLogOutput - RunResult $sendResult - Action " crash-send"
169+ }
170+
123171 # Save crash-send result to JSON for debugging
124172 $sendResult | ConvertTo-Json - Depth 5 | Out-File - FilePath (Get-OutputFilePath " crash-send-result.json" )
125173
@@ -142,12 +190,12 @@ BeforeAll {
142190
143191 $script :Platform = $env: SENTRY_TEST_PLATFORM
144192 if ([string ]::IsNullOrEmpty($script :Platform )) {
145- throw " SENTRY_TEST_PLATFORM environment variable is not set. Expected: Android, Desktop, iOS, or WebGL "
193+ throw " SENTRY_TEST_PLATFORM environment variable is not set. Expected: Android, Desktop, iOS, WebGL, or Xbox "
146194 }
147195
148196 # Validate common environment
149- if ([string ]::IsNullOrEmpty($env: SENTRY_TEST_DSN )) {
150- throw " SENTRY_TEST_DSN environment variable is not set."
197+ if ([string ]::IsNullOrEmpty($env: SENTRY_DSN )) {
198+ throw " SENTRY_DSN environment variable is not set."
151199 }
152200 if ([string ]::IsNullOrEmpty($env: SENTRY_AUTH_TOKEN )) {
153201 throw " SENTRY_AUTH_TOKEN environment variable is not set."
@@ -195,10 +243,25 @@ BeforeAll {
195243 Connect-Device - Platform " iOSSimulator" - Target $target
196244 Install-DeviceApp - Path $env: SENTRY_TEST_APP
197245 }
246+ " Xbox" {
247+ if ([string ]::IsNullOrEmpty($env: XBCONNECT_TARGET )) {
248+ throw " XBCONNECT_TARGET environment variable is not set."
249+ }
250+
251+ Connect-Device - Platform " Xbox" - Target $env: XBCONNECT_TARGET
252+
253+ $xvcFile = Get-ChildItem - Path $env: SENTRY_TEST_APP - Filter " *.xvc" | Select-Object - First 1
254+ if (-not $xvcFile ) {
255+ throw " No .xvc found in SENTRY_TEST_APP: $env: SENTRY_TEST_APP "
256+ }
257+ Install-DeviceApp - Path $xvcFile.FullName
258+ $script :ExecutablePath = Get-PackageAumid - PackagePath $env: SENTRY_TEST_APP
259+ Write-Host " Using AUMID: $ ( $script :ExecutablePath ) "
260+ }
198261 " WebGL" {
199262 }
200263 default {
201- throw " Unknown platform: $ ( $script :Platform ) . Expected: Android, Desktop, iOS, or WebGL "
264+ throw " Unknown platform: $ ( $script :Platform ) . Expected: Android, Desktop, iOS, WebGL, or Xbox "
202265 }
203266 }
204267
@@ -209,7 +272,7 @@ BeforeAll {
209272 # Initialize test parameters
210273 $script :TestSetup = [PSCustomObject ]@ {
211274 Platform = $script :Platform
212- Dsn = $env: SENTRY_TEST_DSN
275+ Dsn = $env: SENTRY_DSN
213276 AuthToken = $env: SENTRY_AUTH_TOKEN
214277 }
215278
0 commit comments