0

I want to publish my static analysis results via Nunit. I am doing so with Pester however this is set in configuration settings with Pester. Is there a way I can do the equivalent when using PS Script Analyzer? I can't find information about it on the documentation.

This is my current code:

- task: PowerShell@2
  inputs:
        targetType: 'inline'
        script: | 
                Install-Module -Name PSScriptAnalyzer
                Invoke-ScriptAnalyzer -Path *
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39

2 Answers2

1

Yes, you need to use an external script in order to be able to do this. You need to be able to translate the results to a Pester test format (XML) and then use Nunit to pubilsh these results.

This article details this process further: https://mathieubuisson.github.io/psscriptanalyzer-first-class-citizen/

You need to use this specific module to translate the Pester result into an XML format: https://github.com/MathieuBuisson/PowerShell-DevOps/tree/master/Export-NUnitXml

0

In Azure DevOps, we usually use Publish Test Results task to publish test results to Azure Pipelines. We can use the test runner of your choice that supports the results format you require. Supported results formats include CTest, JUnit (including PHPUnit), NUnit 2, NUnit 3, Visual Studio Test (TRX), and xUnit 2.

# Publish Test Results
# Publish test results to Azure Pipelines
- task: PublishTestResults@2
  inputs:
    #testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest
    #testResultsFiles: '**/TEST-*.xml' 
    #searchFolder: '$(System.DefaultWorkingDirectory)' # Optional
    #mergeTestResults: false # Optional
    #failTaskOnFailedTests: false # Optional
    #testRunTitle: # Optional
    #buildPlatform: # Optional
    #buildConfiguration: # Optional
    #publishRunAttachments: true # Optional
Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • This doesn't answer the question. I know there is a publish test results task, this isn't what the question is asking - it's specifically about PS Script Analyzer. – i'i'i'i'i'i'i'i'i'i Mar 04 '21 at 14:16
  • Are you able to publish PS Script Analyzer results via Nunit locally? If you can not, it seems the issue is not related to azure-devops or azure-pipelines, but related to psscriptanalyzer, you could modify the tag to get better response. – Cece Dong - MSFT Mar 05 '21 at 03:04