SpecFlow.VisualStudio
SpecFlow.VisualStudio copied to clipboard
Long loading times, high CPU, many related files
SpecFlow Version:
- [X] 2.3
- [ ] 2.2
- [ ] 2.1
- [ ] 2.0
- [ ] 1.9
Used Test Runner
- [ ] SpecFlow+Runner
- [X] MSTest
- [ ] NUnit
- [ ] Xunit
Version number: MsTest bundled with Visual Studio 15.7.3 (?)
Visual Studio Version
- [X] VS 2017
- [ ] VS 2015
- [ ] VS 2013
Are the latest Visual Studio updates installed?
- [X] Yes
- [ ] No
.NET Framework:
- [X] >= .NET 4
- [ ] before .NET 4
Test Execution Method:
- [X] Visual Studio Test Explorer
- [ ] TFS/VSTS – Task
- [ ] Command line
<SpecFlow> Section in app.config
<specFlow>
<unitTestProvider name="MsTest" />
</specFlow>
Repro Project
https://github.com/Feanathiel/SpecFlow-InfLoad-Repro/tree/master/UnitTestProject1
Issue Description
I'd like to put my bindings that are related in a single class, and split them over multiple files using a partial class (see repro project):
- Steps.cs
- Steps.given.area.cs
- Steps.given.anotherarea.cs
- Steps.when.cs
- Steps.then.cs
While loading such solution, it takes forever for the 'go to step definition' to become available, causing high CPU during this period. The referenced repro project is rather small, in terms of implementation details. Currently we're having 91 When's, 1 When and 2 Then's.
Steps to Reproduce
- Enable SpecFlow trace logging
- Open repro solution
- Restore NuGet packages
- Build the project
- Remove SpecFlow cache (AppData\Local*.cache)
- Start Visual Studio
- Open repro solution
- ... wait a long time, notice that go to step definition is unavailable during this time
Trace log
[16:56:59.8882210] GherkinProcessingScheduler: Applying task 'Analyze all starting (BindingFilesTracker)' on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.given1.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.given10.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.given2.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.given9.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.then.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1Steps.when.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze UnitTest1.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze Properties\AssemblyInfo.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1.feature.cs (BindingFilesTracker)' queued on thread: 73 [16:56:59.8917193] GherkinProcessingScheduler: Analyzing request 'Analyze all finishing (BindingFilesTracker)' queued on thread: 73 [16:57:00.3917344] GherkinProcessingScheduler: Applying task 'Analyze all starting (ProjectFeatureFilesTracker)' on thread: 73 [16:57:00.3922362] GherkinProcessingScheduler: Analyzing request 'Analyze SpecFlowFeature1.feature (ProjectFeatureFilesTracker)' queued on thread: 73 [16:57:00.3922362] GherkinProcessingScheduler: Analyzing request 'Analyze all finishing (ProjectFeatureFilesTracker)' queued on thread: 73 [16:57:00.8922419] GherkinProcessingScheduler: Applying task 'Analyze SpecFlowFeature1Steps.given1.cs (BindingFilesTracker)' on thread: 73 [16:57:01.0367400] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given1.cs [16:57:05.8951323] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given8.cs [16:57:05.8951323] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given8.cs [16:57:09.0043569] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given7.cs [16:57:09.0063553] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given7.cs [16:57:11.8291666] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.cs [16:57:11.8311741] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.cs [16:57:14.5329053] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given6.cs [16:57:14.5344048] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given6.cs [16:57:17.1743480] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given5.cs [16:57:17.1753483] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given5.cs [16:57:19.8632061] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given4.cs [16:57:19.8642060] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given4.cs [16:57:22.7402318] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given3.cs [16:57:22.7412329] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given3.cs [16:57:25.4184130] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given2.cs [16:57:25.4194151] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given2.cs [16:57:28.5309885] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.then.cs [16:57:28.5330016] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.then.cs [16:57:31.9158546] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.when.cs [16:57:31.9178286] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.when.cs [16:57:34.6960496] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given10.cs [16:57:34.6970751] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given10.cs [16:57:37.4987815] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.given9.cs [16:57:37.4997880] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.given9.cs ... Repeats [16:57:00.8922419] to [16:57:37.4997880] for every file [17:00:44.4980701] GherkinProcessingScheduler: Applying task 'Analyze all finishing (ProjectFeatureFilesTracker)' on thread: 73
Or in another trace:
... [15:06:03.4545936] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.then.cs [15:06:14.3633448] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.when.cs [15:06:14.3653334] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.when.cs [15:18:06.8919295] BindingFilesTracker: Analyze related file SpecFlowFeature1Steps.cs [15:18:06.8973949] BindingFilesTracker: Analyzing binding file: SpecFlowFeature1Steps.cs ...
@Feanathiel If you don't use partial classes, does it work? We are parsing somehow the C# code and I am not sure if we support partial classes.
@SabotageAndi Then the bindings are analyzed almost instantly. Are partial classes going to be supported in the future, or should they be rewritten to be non-partial? Thank you for your time.
@Feanathiel Found any work around? I am facing the same issue.
@aditki What I did so far is copy every constructor and field to every partial class and remove the partial keywords. I did not have any calls to (private) members, so that was a rather easy fix to do. All handling was done by the class that I provided in the constructor (the instance is shared between steps, but not between test cases).
@Feanathiel But i dont have any partial classes. I am using a plugin Specflow retry.
@aditki I think this is a different issue from what I'm facing. It could be related, but I suggest you create a new issue with reproduction steps.
Ya i did thanks.