SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

dotnet vstest when called in publish folder skips all tests #2041

Closed keenth closed 3 years ago

keenth commented 4 years ago

All tests are running fine in Visual Studio but when running the tests in the command line using dotnet vstest from the publish folder all tests are skipped. I have tried to set <Environment testThreadIsolation="SharedAppDomain" /> in Default.srprofile but still facing the same issue.

SpecFlow+ Runner Version:

SpecFlow Version:

Used Test Runner

Version number: 3.2.15

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

image

<SpecFlow> Section in app.config or content of specflow.json

image

{
  "bindingCulture":
  {
    "language": "en-us"
  },
  "language":
  {
    "feature": "en-us"
  },
  "plugins": []
}

Repro Project

Issue Description

Here is the log info, then I found that the two missing DLLs are located in the folder SpecFlowPlusRunner\netcoreapp3.1 but I don't know why they are not in the root publish folder.

image

 ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.VisualStudio.Validation, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Invalid pointer (0x80004003 (E_POINTER))
File name: 'Microsoft.VisualStudio.Validation, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at TechTalk.SpecRun.Framework.TestThread.UnpackTestThreadExecutorInfoResult(IResult`1 testThreadExecutorInfoResult)
   at TechTalk.SpecRun.Framework.TestThread.InitializeTestThreadExecutor(IAssemblyReference testAssembly, ExecutionModelSettings executionModelSettings, String testTarget)
   at TechTalk.SpecRun.Framework.TestThread.GetThreadExecutor(IAssemblyReference testAssembly, ExecutionModelSettings executionModelSettings, String testTarget)
   at TechTalk.SpecRun.Framework.TestThread.GetThreadExecutorForTestItem(TestItem testItem)
   at TechTalk.SpecRun.Framework.TestThread.RunNonEmptyTestSuite(CancellationToken cancellationToken, TestThreadState testThreadState)
   at TechTalk.SpecRun.Framework.TestThread.Run(ITestExecutionManager executionManagerForRun, CancellationToken cancellationToken)
   at TechTalk.SpecRun.Framework.AsyncTestThreadRunner.RunSync(TestExecutionManager executionManager, CancellationToken cancellationToken)

Steps to Reproduce

  1. In VS publish the tests project
  2. In the CMD, run command "C:\Program Files\dotnet>dotnet vstest "C:\Drop\SpecFlow.Tests.dll"
SabotageAndi commented 4 years ago

The problem is not the dotnet vstest command, the problem is, the publishing before.

keenth commented 4 years ago

Thank you @SabotageAndi, do you mean that during the publishing, the two missing DLLs (Microsoft.VisualStudio.Threading.dll and Microsoft.VisualStudio.Validation.dll)should be copied from SpecFlowPlusRunner\netcoreapp3.1 folder to the root publish folder? So it is the Visual Studio issue?

SabotageAndi commented 4 years ago

I think it's a SpecFlow+ Runner issue and we don't handle the case of publishing the test project correctly. Does it work if you copy these two assemblies to your publishing folder?

keenth commented 4 years ago

Yes @SabotageAndi, If I copy the two DLLs to the publishing folder, all tests are running fine.

SabotageAndi commented 4 years ago

Cool, so you have a workaround until we fixed this issue.

keenth commented 4 years ago

We run the tests in the Azure release pipeline as well after publishing. I created a new task to copy the missing DLLs and the tests are running now. Thank you @SabotageAndi for your help.

image

SabotageAndi commented 3 years ago

We fixed this issue with a release in the past.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.