0

I have a YAML-pipeline that builds my code and runs some tests. My code-base is pretty huge and full of weird legacy-code that fails my unit-tests. This is why I want to track only new errors within my code, while those legacy-errors should be ignored.

- script: "nunit3-console.exe" MyAssembly.dll
  displayName: 'Run unit-tests'
  failOnStderr: false
  continueOnError: true            

When executing that script I get a partially successful build, because the exit-code of nunit is 5:

task run unit-tests

As I want only new errors to make the build fail, I also implemented a quality-gate:

- task: BuildQualityChecks@8
  displayName: 'Check for test-errors'
  inputs:
      checkWarnings: true
      warningFailOption: 'build'
      warningTaskFilters: '/^Run unit-tests$/i'
      warningFilters: |
          /\d+\) Error :/i
          /\d+\) Failed :/i

However the entire build stays "partially successfull" because of the previous task. Is there any way to ignore the outcome of the Run unit-tests-task, as I manage them within the quality-gate ayway?

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111

2 Answers2

0

You can set the exit-code for your script-task:

- script: |
    "nunit3-console.exe" MyAssembly.dll
    exit 0
  displayName: 'Run unit-tests'
  failOnStderr: false

Now that task allways succeeds. Notice that I also ommited the continueOnError-property, as the task never produced any error.

MakePeaceGreatAgain
  • 35,491
  • 6
  • 60
  • 111
0

You can do by calling it from python.

- script: python -c "import os; os.system('nunit3-console.exe MyAssembly.dll'); print('FINISHED')" 
  displayName: 'Run unit-tests'
  failOnStderr: false
  continueOnError: true        

This task just succeeds, also when there are errors.

Daan
  • 2,478
  • 3
  • 36
  • 76