I was reminded recently of the hoops you have to jump through to run UWP unit tests within an Azure DevOps automated build.
The key steps you need to remember are as follows
The build agent should not be running as a service it must be able to interact with the desktop.
If you did not set this mode during configuration this post from Donovan Brown shows how to swap the agent over without a complete reconfiguration.
The UWP unit test projects are not built as a DLL, but as an EXE.
I stupidly just made my VSTest task look for the generated EXE and run the tests they contained. This does not work generating the somewhat confusing error
Test run will use DLL(s) built for framework .NETFramework,Version=v4.0 and platform X86. Following DLL(s) do not match framework/platform settings.
BlackMarble.Spectrum.FridgeManagement.Client.OneWire.UnitTests.exe is built for Framework .NETCore,Version=v5.0 and Platform X86.
What you should search for as the entry point for the tests is the .appxrecipe file. Once tI used this my tests ran.
So my pipeline YML to run all the tests in a built solutions was
- task: VisualStudioTestPlatformInstaller@1
- task: VSTest@2
displayName: 'VSTest - testAssemblies'
testAssemblyVer2: | # Required when testSelector == TestAssemblies
- task: PublishTestResults@2
displayName: 'Publish Test Results **/TEST-*.xml'