The hybrid approach combines the strengths of both zero-code and programmatic methods. It is useful when testing specific areas of an application that are not accessible at the begining of gameplay. Here, the zero-code automation can navigate the game to the desired location and be followed by programmatic testing to scrutinize the application’s behavior in that context.
By following this guide, you will be able to set up and run hybrid automation tests against the Oculus Unity-StarterSamples project. The steps are outlined below:
Record a zero-code automation test to bring the game to a certain stage.
Set Meta XR Simulator to replay the recording.
Prepare programmatic testing and execute the test.
Download and build the test app
Run the following script in Powershell to download and build the game to .exe:
# Clone project source code
cd c:/
mkdir tmp
cd tmp
git clone https://github.com/oculus-samples/Unity-StarterSamples.git
# Build project into .exe
C:\”Program Files”\Unity\Hub\Editor\2022.3.20f1\Editor\Unity.exe -buildTarget win64 -openfile "C:\tmp\Unity-StarterSamples/Assets/StarterSamples/Usage/SceneManager.unity" -buildWindows64Player "c:/tmp/output/game.exe" -logFile c:/tmp/log.txt -quit
Download Meta XR Simulator
Run the following script in PowerShell to download and install the Meta XR Simulator and then launch the game. These commands can be run alongside the previous script but are separated here for clearer tutorial structure.
# 1. Download and Unzip Meta XR Simulator [Start]
# If you already have Meta XR Simulator install, skip to the next step of this script. (Note: the download progress can take up to 5 minutes. Alternatively you can manually download it from https://developer.oculus.com/downloads/package/meta-xr-simulator/)
cd c:/tmp
Invoke-WebRequest -Uri https://npm.developer.oculus.com/com.meta.xr.simulator/-/com.meta.xr.simulator-65.0.0.tgz -OutFile MetaXRSimulator.tgz
tar -xvzf "MetaXRSimulator.tgz"
Start-Sleep 1
Rename-Item -Path "package" -NewName "MetaXRSimulator"
# Download and Unzip Meta XR Simulator [End]
Record test on Meta XR Simulator
Run the following script below to start the app for recording.
# 1. Launch a Synthetic Environment
Start-Process -FilePath "C:/tmp/MetaXRSimulator/MetaXRSimulator\.synth_env_server\synth_env_server.exe" -ArgumentList "Bedroom" -PassThru
# 2. Activate Meta XR Simulator
c:/tmp/MetaXRSimulator/MetaXRSimulator/activate_simulator.ps1
mkdir C:\tmp\test_recordings\
# 3. Launch the game
Start-Process -FilePath "C:\tmp\output\game.exe" -Wait
# 4. Deactivate Meta XR Simulator
C:\tmp\MetaXRSimulator\MetaXRSimulator\deactivate_simulator.ps1
# 5. Stop Synthetic Environment
Get-Process -Name "synth_env_server" | Stop-Process
Click Record & Replay > Record to start a recording. Select a VRS file to record to (for example, C:\tmp\test_recordings\recording.vrs).
Interact with the game on Meta XR Simulator, for demo purpose we will only walk around with AWSD key on the keyboard.
Click Stop Recording button to stop the recording.
Close Meta XR Simulator.
Set Meta XR Simulator to replay the recording
Run the following script to configure the Simulator for replaying the recorded session.
Note that delay_start_ms is required to ensure the target scene is fully loaded.
For the programmatic testing segment, reuse all scripts from Programmatic Automation Testing. However, adjust yield return new WaitForSeconds(10); to a longer duration (for example, 20) to ensure the recording is replayed before assertions.
When it runs, you will see the test scene load, followed by the automatic replay of the recording. After that, the test runner will execute and the test results will be displayed.