Codementor Events

Making sure XUnit tests run on Azure DevOps

Published Jan 23, 2020

Lately I was (and am still developing) an asp.net core webservice and website for which I have written some unit and integration tests. However, after checking in and building, the tests didn’t run. Checking my testlog revealed that the testrunner was looking for dlls built for .NET framework, not for .NET core. It took me some days of searching, but finally I found the solution, simply add this snippet to your pipeline.yml

- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    arguments: '/Framework:.NETCoreApp,Version=3.0'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      ! **\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'
    vsTestVersion: '16.0'

Make sure you change the version .NET core appropiately. Also make sure that your test-dlls are found (the ! in front the filenames means that they are not searched for tests). That is it, again, simple, but looking for the solution can be frustrating

Discover and read more posts from Iede Snoek
get started