Open Pressacco opened 2 years ago
Related to:
Symptoms:
Implementation Notes:
AssemblyInitialize
attribute in conjunction with SpecFlow's test run hooks.AssemblyInitialize
.v2.0.0
library.The following Gherkin scenario is failing with a run-time error:
[TestMethod]
public async Task OpenAsync()
{
// InvalidOperationException: The calling thread must be STA, because many UI components require this.
var window = Substitute.For<Window>();
}
With Just My Code disabled, you can see that the error is ultimately due to a .NET guard failing:
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.VSInstallationUtilities.cs:
public static string? VSInstallPath
{
// ...
// Use the Setup API to find the installation folder for currently running VS instance.
if (new SetupConfiguration() is ISetupConfiguration setupConfiguration)
{
var currentConfiguration = setupConfiguration.GetInstanceForCurrentProcess();
// ...
}
}
Window
?
About
and Dashboard
dialogs.Window
reference when displaying Open As
? <<<STA Thread
Visual Studio is displaying weird compiler errors & warnings
AndDiscoveryProviderSucceed: Error during binding discovery
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0
JsonReaderException: Unexpected character encountered while parsing value
AndDiscoveryProviderSucceed: The project bindings (e.g. step definitions) could not be discovered. Navigation, step completion and other features are disabled.
In Visual Studio:
HowTo: Write Gherkin Scenarios
Scenario Titles
There isn't a single "one-size-fits-all" approach to naming Gherkin scenarios, but there are best practices that can make scenarios more understandable and maintainable. These practices aim to make the scenario name descriptive enough to understand its purpose at a glance while being concise enough to be easily digestible. Here are some guidelines:
Examples following these guidelines might look like:
"Successful login with valid credentials"
"Error on empty shopping cart checkout"
"Admin access denied for regular users"
"Open log file with valid format"
"Error on opening corrupted log file"
Lessons Learned
Single Quote / Double Quote / Backtick text formatting works for...
Relates To
362
Articles