Skip to main content

All Specflow MSTests running in the background after single test run when started from Visual Studio Test-Explorer

Comments

11 comments

  • Jordan Western

    Hi Pierrot Macala,

    Thanks for getting in touch.

    Obviously this should not be the case so let's try and understand the behavior.

    Would you be able to send me a screenshot of the text explorer window after the execution has completed?

    Also, would you be able to share some details regarding the test you are running; maybe how you are setting up the execution and the steps themselves?

    Hopefully we can get to the bottom of the issue in good time.

    Many thanks, Jordan.

    0
  • Pierrot Macala

    Hello Jordan,

    yes of course. Here is a example project to reproduce the problem. The project structure looks like this:

    Here is my feature file:

    Feature: Write Files
    Put feature description here

    Scenario: Write A in file
    When always
    Then Write A in the tmp.txt file

    Scenario: Write B in file
    When always
    Then Write B in the tmp.txt file

    Scenario: Write C in file
    When always
    Then Write C in the tmp.txt file

    This is my Steps.cs file:

    using System;
    using System.IO;
    using TechTalk.SpecFlow;

    namespace SpecFlowTempProj.StepDefinitions
    {
    [Binding]
    public class Steps
    {
    [When(@"always")]
    public void WhenAlways()
    {
    // do nothing
    }

    [Then(@"Write A in the tmp\.txt file")]
    public void ThenWriteAInTheTmp_TxtFile()
    {
    File.AppendAllText(@"C:\Users\PIERRE\Documents\tmp\tmp.txt", $"{Environment.NewLine}{DateTime.Now} A");
    }

    [Then(@"Write B in the tmp\.txt file")]
    public void ThenWriteBInTheTmp_TxtFile()
    {
    File.AppendAllText(@"C:\Users\PIERRE\Documents\tmp\tmp.txt", $"{Environment.NewLine}{DateTime.Now} B");
    }

    [Then(@"Write C in the tmp\.txt file")]
    public void ThenWriteCInTheTmp_TxtFile()
    {
    File.AppendAllText(@"C:\Users\PIERRE\Documents\tmp\tmp.txt", $"{Environment.NewLine}{DateTime.Now} C");
    }
    }
    }

    I compile and then run only the first test from the Test-Explorer, the window looks like this after the test:

    And my tmp.txt file contains the following:

    7/29/2021 9:12:50 AM A
    7/29/2021 9:12:58 AM A
    7/29/2021 9:12:58 AM B
    7/29/2021 9:12:58 AM C

    A colleague of mine has the same problem on another computer.

    Thanks, Pierre

    0
  • Pierrot Macala

    Hello,

    have you been able to reproduce this behavior on your computer?

    Thanks,

    Pierre

    0
  • Jordan Western

    Hi Pierrot Macala,

    I will take a look this morning and get back to you.

    0
  • Jordan Western

    Hi again Pierrot Macala,

    I am not faced with the same issue, the only difference I can see is the package versions -

    I created a new project from the SpecFlow template, .net 4.8 using MSTest from the dropdown.

    1. One test run

    2. Second test run (ran all tests)

    I can't think of why this might be a problem for you, can you try updating the packages and see if this still causes you an issue?

    Thanks

    0
  • Pierrot Macala

    Hello,

    I wanted to give a quick feedback, I tried SpecFlow on another computer and it worked as expected. It seems my problem is not only with SpecFlow but a general problem with MSTest on this specific computer (maybe? still looking for the source of the problem...). 

    Thanks for the feedback

    Pierre

    0
  • Jordan Western

    Hi Pierrot Macala,

    I honestly cant think of what might be causing this type of issue, other than running all the tests!

    Is there any way you can share this project? Looks like just a new one slightly modified?

    0
  • Joe Robe

    This is an old thread but I just installed specflow in my machine and have the same issue. I have hundreds of tests and hundreds of windows open after just running ONE test. When I debug the tests, the tests finshes and VS gets out of debug mode and the that gazillons of windows open

    1
  • Mike Hingley

    I'm seeing the same - except I'm running nunit, Specflow. 

     

    I'm going to see if I can do some more digging.  And find out what is causing it

    0
  • Mike Hingley

    I found out what was causing my issue - I have a simple project that replicates the issue.

    What I found was that I was running Fine Code Coverage extension - and that seemed to be causing the tests to execute.

    My suggestion might be to disable all extensions, and then re-add them back in one by one.  One thing I did find was that running the test individually via the CLI worked fine - so I started googling how to debug issues with Test Explorer - and found this stack exchange article.

    I thought “well - it's possible that it is fine coverage that is getting involved here - so maybe I could deactivate it to confirm” - and that worked fine.

    1
  • Rouèche, Jérémy

    Mike Hingley What a great comment! Disabling the extension solved the issue for me.

    0

Please sign in to leave a comment.

Powered by Zendesk