All Specflow MSTests running in the background after single test run when started from Visual Studio Test-Explorer
Hello,
I realized, that when I start a single SpecFlow test from the Test-Explorer in Visual Studio, the test will be correctly executed, but after the test ends it looks like all the SpecFlow tests run in the background. I noticed this because I control some electromechanical relays in my test and they are toggling after the test ends but this is not the point, you can check this behavior if you append some text in a temp file during your tests as well: the test you start writes in the file, the tests you did not start also. I am using Visual Studio 2019, I created a SpecFlow test project for the MSTEST unit test provider targetting dotnet Framework 4.8 using the extension. Is there a way to not have this behavior?
Cheers,
Pierre
-
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 -
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 fileThis 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 CA colleague of mine has the same problem on another computer.
Thanks, Pierre
0 -
Hello,
have you been able to reproduce this behavior on your computer?
Thanks,
Pierre
0 -
Hi Pierrot Macala,
I will take a look this morning and get back to you.
0 -
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 -
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 -
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.
Comments
7 comments