4

I have researched a lot before posting the question but I could not find a solution to fix my issue.

I am trying to use selenium to do automation testing, but the issue is that my test explorer is not picking up the specflow tests for some reason.

Here is what I am using:

  • c# .net core project
  • Specflow
  • Xunit
  • Selenium driver
  • Selenium Chrome Driver

NuGet Packages I have installed:

  • Selenium.Support
  • Selenium.WebDriver
  • Selenium.WebDriver.ChromeDriver
  • Specflow
  • Specflow.NetCore
  • Specflow.xUnit
  • SpecRun.Runner
  • xunit
  • xunit.core
  • xunit.runner.visualstudio

I also have the Specflow for Visual Studio 2017 installed.

I have installed and Uninstalled loads of NuGet packages to try and fix this issue. Anyone able to help me please?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
MaZami
  • 81
  • 1
  • 10
  • Also, when I build the solutions it throws me this error: [30/01/2019 10:15:46 Error] An exception occurred while invoking executor 'executor://specrun/executorV3.0.194': Exception has been thrown by the target of an invocation. Could not load file or assembly 'TechTalk.SpecRun.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=d0fc5cc18b3b389b'. The system cannot find the file specified. ======== – MaZami Jan 30 '19 at 10:17
  • 1
    You don't need 2 runners. I'd remove SpecRun.Runner. – bilpor Jan 30 '19 at 11:34
  • I did do that, but not it says o test is available in home\username\Documents\Visual Studio 2017\Projects\TestSelenium\TestSelenium\bin\Debug\netcoreapp2.1\TestSelenium.dll. – MaZami Jan 30 '19 at 11:49
  • Related post - [Built tests are not added to the Visual Studio Test Explorer window](https://stackoverflow.com/q/30573482/465053) – RBT Feb 17 '21 at 05:21

4 Answers4

4

After a lot of trying, I finally fixed. After deleting one of the the runners, SpecRun, I added the Specflow.Tools.MSbuild.Generation NuGet Package and it fixed the problem.

Hope it is useful for someone with the same issue!

MaZami
  • 81
  • 1
  • 10
1

If you are encountering the problem, and have already installed Specflow.Tools.MSBuid.Generation NuGet package in your project, and you intermittently lose your generated tests, then you should be aware that there is a bug in Specflow.Tools.MSBuild.Generation Version=2.3.2

You can upgrade to a newer version of Specflow.Tools.MSBuild.Generation or apply a workaround.

The workaround is to edit your .csproj and add a section after AfterUpdateFeatureFilesInProject.

<Target Name="AfterUpdateFeatureFilesInProject">
  <ItemGroup>
    <Compile Include="@(SpecFlowGeneratedFiles)" />
  </ItemGroup>
</Target>

<!-- Workaround Specflow 2.3 MSBuild bug. SpecFlowGeneratedFiles 
     is not set if UpdateFeatureFilesInProject is up-to-date
   causing tests not to be discovered, as they are not included in the project -->
<ItemGroup>
  <Compile Include="**/*.feature.cs" Exclude="@(SpecFlowGeneratedFiles)">
    <DependentUpon>%(Filename)</DependentUpon>
  </Compile>
</ItemGroup>
Chui Tey
  • 5,436
  • 2
  • 35
  • 44
0

Seems to me that you could be missing the Reference to TechTalk.SpecRun.Common. Please check that this is in your solution references.

If it is Referenced, your Test Adapter cache might be corrupted. Try having a look through these steps: Troubleshooting Visual Studio Integration

  • I removed the SpecRun NuGet packages, because I also have the Xunit Runner, but now it says "No Test is available in..." – MaZami Jan 30 '19 at 11:50
0

I added the Specflow.xUnit NuGet Package and it fixed the problem. (NetCore 5)