如何配置 RestSharp 测试以在 AzureDevOps 上运行

问题描述 投票:0回答:1

这是我第一次使用RestSharp + NUnit 实现测试框架。我没有在 Restsharp 页面上看到任何说明它支持 AzureDevOps 的信息。

我只是想知道有人在 AzureDevOps 上成功运行 RestSharp 测试吗?

谢谢。

我目前正在本地计算机上的 RestSharp 上进行 POC。我希望能够在 Azure 管道上运行测试。我想知道是否有人成功实施了这一点。 RestSharp 支持 AzureDevOps 吗?

c# azure-devops azure-pipelines nunit restsharp
1个回答
0
投票

是的,支持在 Azure DevOps 上使用 NUnit 运行 RestSharp 测试。

在 azure-pipelines.yml 文件中,您需要指定恢复 NuGet 包、构建解决方案和运行测试的步骤。

这里是基于 RestSharp 测试的 yaml 示例,在 github 存储库上使用 NUnit 进行测试

trigger: none

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'
  solution: '**/*.sln'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\$(BuildConfiguration)\*DataDriven*.dll    # this is the test dll built in above step
      **\$(BuildConfiguration)\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'

测试结果通过:

enter image description here

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.