SpecFlow + VSTS/TFS 2015

2019-05-30 21:02发布

问题:

Using the new build system in TFS2015/VSTS, my SpecFlow tests aren't getting picked up. Within the same project, classes and methods decorated with [TestClass] and [TestMethod], respectively, are picked up and tested by TFS. What are the basic requirements for TFS2015/VSTS to run a SpecFlow 2.0 test?

EDIT: Adding packages.config contents. As you can see, I have SpecRun installed, and from within Visual Studio, I'm able to run SpecFlow tests as I'd expect (i.e. they all appear in Test Explorer)

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="NUnit" version="3.0.1" targetFramework="net452" />
  <package id="SpecFlow" version="2.0.0" targetFramework="net452" />
  <package id="SpecRun.Runner" version="1.3.0" targetFramework="net452" />
  <package id="SpecRun.SpecFlow" version="1.3.0" targetFramework="net452" />
</packages>

回答1:

Edit you VS Test Task and set the Path to Custom Test Adapters` to where in Source Control your "packages" folder lives.

For example:

$(Build.SourcesDirectory)\packages



回答2:

Already looked at this answer? Built tests are not added to the Visual Studio Test Explorer window

  1. Close all Visual Studio instances
  2. Go to %TEMP%\VisualStudioTestExplorerExtensions\
  3. Delete all the folders in here
  4. Try again

This helped me out this morning (VS2017, SpecFlow Version:2.1.0.0, SpecFlow+ Excel Version:1.4.2.0).