我已经配置了VSTS构建作业,以从GitHub构建我的MockingFrameworkExamples .NET 4.7.1(C#)解决方案。该解决方案包括五个具有NUnit v3.10单元测试的程序集。
我在构建定义中包括了一个Visual Studio Test
步骤,但是当它运行时,控制台输出显示测试程序集中没有可用的测试:
D:\ a \ 1 \ s \ MSFakesExamples \ bin \ Release \ MSFakesExamples.dll D中没有任何测试D:\ a \ 1 \ s \ MoqExamples \ bin \ Release \ MoqExamples.dll D:\ a \ 1 \ s \ NSubstituteExamples \ bin \ Release \ NSubstituteExamples.dll D:\ a \ 1 \ s \ RhinoMocksExamples \ bin \ Release \ RhinoMocksExamples.dll。确保已注册测试发现者和执行者,并且平台和框架版本设置正确,然后重试。
要让测试运行程序查找并运行测试,我需要更改什么?
我的本地Visual Studio 2017实例在查找和运行测试方面没有问题。 documentation for the Visual Studio Test
step说它将运行NUnit测试:
具有Visual Studio测试适配器(例如xUnit,NUnit,Chutzpah等)的测试框架也可以运行。
我已经确保程序集确实在构建,并且我还利用了Typemock SmartRunner
构建步骤来运行测试,该测试找到并执行了这些测试(尽管MS Fakes程序集失败了,所以我不能只是使用它。)
下面是完整的构建步骤配置和“ Visual Studio测试”步骤的控制台输出。构建过程配置为在“托管VS2017”代理上运行。
2018-07-19T18:28:28.1197107Z ##[section]Starting: VsTest - testAssemblies
2018-07-19T18:28:28.1205564Z ==============================================================================
2018-07-19T18:28:28.1205798Z Task : Visual Studio Test
2018-07-19T18:28:28.1206209Z Description : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test runner. Test frameworks that have a Visual Studio test adapter such as xUnit, NUnit, Chutzpah, etc. can also be run. Tests can be distributed on multiple agents using this task (version 2).
2018-07-19T18:28:28.1206596Z Version : 2.136.10
2018-07-19T18:28:28.1206775Z Author : Microsoft Corporation
2018-07-19T18:28:28.1207003Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)
2018-07-19T18:28:28.1207231Z ==============================================================================
2018-07-19T18:28:28.6970694Z Run the tests locally using vstest.console.exe
2018-07-19T18:28:28.6971006Z ========================================================
2018-07-19T18:28:28.6971725Z Test selector : Test assemblies
2018-07-19T18:28:28.6972103Z Test assemblies : **\release\*examples*.dll,!**\release\typemock*examples*.dll,!**\obj\**
2018-07-19T18:28:28.6972430Z Test filter criteria : null
2018-07-19T18:28:28.6972706Z Search folder : D:\a\1\s
2018-07-19T18:28:28.6972990Z Run settings file : D:\a\1\s
2018-07-19T18:28:28.6973481Z Run in parallel : false
2018-07-19T18:28:28.6973748Z Run in isolation : false
2018-07-19T18:28:28.6975710Z Path to custom adapters : null
2018-07-19T18:28:28.6975982Z Other console options : null
2018-07-19T18:28:28.6976254Z Code coverage enabled : true
2018-07-19T18:28:28.6976788Z Rerun failed tests: false
2018-07-19T18:28:28.6977166Z VisualStudio version selected for test execution : latest
2018-07-19T18:28:29.7035629Z ========================================================
2018-07-19T18:28:30.0191054Z [command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @D:\a\_temp\88c64f61-8b81-11e8-a282-258e7155540f.txt
2018-07-19T18:28:33.5193511Z Microsoft (R) Test Execution Command Line Tool Version 15.7.2
2018-07-19T18:28:33.5198868Z Copyright (c) Microsoft Corporation. All rights reserved.
2018-07-19T18:28:33.5199025Z
2018-07-19T18:28:33.5440200Z vstest.console.exe
2018-07-19T18:28:33.5441525Z "D:\a\1\s\MSFakesExamples\bin\Release\MSFakesExamples.dll"
2018-07-19T18:28:33.5442179Z "D:\a\1\s\MoqExamples\bin\Release\MoqExamples.dll"
2018-07-19T18:28:33.5442549Z "D:\a\1\s\NSubstituteExamples\bin\Release\NSubstituteExamples.dll"
2018-07-19T18:28:33.5442909Z "D:\a\1\s\RhinoMocksExamples\bin\Release\RhinoMocksExamples.dll"
2018-07-19T18:28:33.5443312Z /EnableCodeCoverage
2018-07-19T18:28:33.5443575Z /logger:"trx"
2018-07-19T18:28:35.6891585Z Starting test execution, please wait...
2018-07-19T18:28:42.3946126Z Microsoft (R) Coverage Collection Tool Version 15.0.30319.1
2018-07-19T18:28:42.3947458Z
2018-07-19T18:28:42.3947721Z
2018-07-19T18:28:42.3948539Z Copyright (c) Microsoft Corporation. All rights reserved.
2018-07-19T18:28:42.3949162Z
2018-07-19T18:28:42.3949300Z
2018-07-19T18:28:42.3949487Z
2018-07-19T18:28:42.3949624Z
2018-07-19T18:28:42.6811429Z 2.7184
2018-07-19T18:28:53.8206723Z No test is available in D:\a\1\s\MSFakesExamples\bin\Release\MSFakesExamples.dll D:\a\1\s\MoqExamples\bin\Release\MoqExamples.dll D:\a\1\s\NSubstituteExamples\bin\Release\NSubstituteExamples.dll D:\a\1\s\RhinoMocksExamples\bin\Release\RhinoMocksExamples.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
2018-07-19T18:28:53.9442220Z Microsoft (R) Coverage Collection Tool Version 15.0.30319.1
2018-07-19T18:28:53.9443798Z
2018-07-19T18:28:53.9445199Z
2018-07-19T18:28:53.9465185Z Copyright (c) Microsoft Corporation. All rights reserved.
2018-07-19T18:28:53.9465983Z
2018-07-19T18:28:53.9466184Z
2018-07-19T18:28:53.9466360Z
2018-07-19T18:28:53.9466554Z
2018-07-19T18:28:54.6483114Z
2018-07-19T18:28:54.6491201Z Attachments:
2018-07-19T18:28:54.6491635Z D:\a\1\s\TestResults\324c9712-62bd-4959-b3b6-40bebf7c05ec\VssAdministrator_factoryvm-az243 2018-07-19 18_28_41.coverage
2018-07-19T18:28:54.6491944Z
2018-07-19T18:28:54.6574103Z Additionally, path to test adapters can be specified using /TestAdapterPath command. Example /TestAdapterPath:<pathToCustomAdapters>.
2018-07-19T18:28:54.6717566Z ##[warning]No results found to publish.
2018-07-19T18:28:54.7119869Z ##[section]Finishing: VsTest - testAssemblies
答案 0 :(得分:5)
事实证明,我必须在NUnit3TestAdapter NuGet程序包中添加对每个单元测试程序集的NuGet引用,才能正常工作。无需其他配置。
答案 1 :(得分:-1)
您需要使用/TestAdapterPath
指定NUnit适配器的路径。