Can I run Xamarin UITests on windows self hosted agent and azure pipelines?

Viewed 335

I have a hard time finding in docs if I can run the Xamarin UITests on self-hosted windows agent and Azure DevOps build pipelines..

Thanks

2 Answers

Here is what I've tried to do, it is still working in progress. Right now I have problems when the self hosted agent starts the emulator from the script I get Device unauthorized, but if I start the emulator manually without using the script task pipeline the UITest are executed on the device, so I partially succeded.

What I ended doing:

  1. I installed the Xamarin Build Tools for Visual Studio

  2. Installed a Android Emulator and added the emulator.exe to my Path environment variable.

  3. Wrote a PowerShell script to start the emulator at the start of my build pipeline.

The build pipeline task:

 - task: PowerShell@2
   displayName: 'Run Android Emulator'
   inputs:
     filePath: './run_emulator.ps1'
     arguments: '-ExecutionPolicy Unrestricted'

run_emulator.ps1 script:

Start-Process -FilePath "emulator" -ArgumentList  "-avd pixel_2_pie_9_0_-_api_28"

4. Built the Apk for my app using the following build pipeline task:
 - task: XamarinAndroid@1
   inputs:
     projectFile: '.\tests\TestApp\TestApp.Android\TestApp.Android.csproj'
     msbuildArguments: '/t:restore'
     jdkOption: 'JDKVersion'
  1. Run the UITest with VSTest@2:
 - task: VSTest@2
  displayName: 'Running UITests for Xamarin'
   inputs:
     testSelector: 'testAssemblies'
     testAssemblyVer2: |
       **\*TestApp.UITests.dll
       !*testhost.dll 
       !**\*testhost.dll
       !**\obj\**
       !**\xunit.runner.visualstudio.testadapter.dll
       !**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
       !**\NUnit3.TestAdapter.dll
       !**\Xamarin.UITest.dll
     searchFolder: './tests/TestApp/'
     platform: '$(buildPlatform)'
     configuration: '$(configuration)'

I thought that this might help someone trying to accomplish the same thing as me.

Related