3

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

David Petric
  • 324
  • 3
  • 17

2 Answers2

3

I think you can use the appcenter test task, you will need to have node 10 on your agent.

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/test/app-center-test?view=azure-devops

https://learn.microsoft.com/en-us/appcenter/test-cloud/vsts-plugin

After the test is done you need the Publish Test Results task , point it to your xml of results.

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-test-results?view=azure-devops&tabs=yaml

Rui Marinho
  • 1,692
  • 12
  • 20
  • Hello Rui, thank you so much for your answer and sorry for late response I was in bank holiday. I will try your solution and will comeback with an answer as per now I have to do other things. – David Petric Jun 09 '20 at 06:59
3

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.

David Petric
  • 324
  • 3
  • 17