Skip to main content

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

Comments

7 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

Please sign in to leave a comment.

Powered by Zendesk