Specflow overwriting original exception stack trace - c#

Do any of you know a workaround that would turn off the behaviour mentioned in the title? Each time I do something wrong in my test steps, the exception looks like below:
Test method
FunctionalTests.Features.Parties.PartyAddingFeature.FeatureTitle threw exception:
TechTalk.SpecFlow.BindingException: Error calling binding method 'FunctionalTests:FunctionalTests.Steps.PartiesSteps.GivenLegacyPartyUpsertedIntegrationEventCameInWithData(String, Table)': Object of type 'System.String' cannot be converted to type 'System.Int32'.
at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) in D:\a\1\s\TechTalk.SpecFlow\Bindings\BindingInvoker.cs:line 69
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 395
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 316
at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep() in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs:line 132
at FunctionalTests.Features.Parties.PartyAddingFeature.ScenarioCleanup()
at FunctionalTests.Features.Parties.PartyAddingFeature.FeatureTitle() in C:\Project\test\Services\FunctionalTests\Features\Parties\PartyAdding.feature:line 25

By your opinion, what should be correct exception for this situation?
I mean, we don’t see or know your code. And by stack trace you posted, it indicates that you have situation with parameter conversion before entering one of Given/when/then method.

Related

What is causing visual studio errors looking for defaultbinder.cs?

Just reinstalled visual studio 2019 as I was getting this error: https://github.com/dotnet/roslyn/issues/18814
I have never seen it before. After reinstalling, I no longer see it but I get something else. "Source not found" looking for defaultbinder.cs when running my WPF application from the debugger. Running it outside of the debugger works fine.
I know I have seen this before but I couldn't find any info on the web. -
$exception {"Object reference not set to an instance of an
object."} System.NullReferenceException
at System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, Object& state) in f:\dd\ndp\clr\src\BCL\system\defaultbinder.cs:line 66
at MS.Internal.Xaml.Runtime.DynamicMethodRuntime.CreateInstanceWithCtor(Type type, Object[] args)
at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateInstance(XamlType xamlType, Object[] args)
As Kyle mentioned, just my code should be enabled. This allowed me to start the application. Hope this helps someone else or if no one else, me when I come looking for it a year from now.

Can't get a Allure report to be generated in c# specflow .net Core. Value cannot be null. (Parameter 'key') Value cannot be null. OnScenarioStart();

I have written a C# test automation Framework on .netcore 3.1 that is using Specflow and Specrun.
I can run the tests with Specrun and get a report, however I would like to get an Allure report.
So I have installed Specflow.Allure. I have an allureConfig.json.
I was hoping that I could now just run the tests and get an Allure report.
However it seems it is not that simple.
When I try to run the tests if fails with the message shown below.
Anyone know what I am doing wrong? Do I need to add more code in order to get the Allure report?
Message:
Value cannot be null. (Parameter 'key')
Stack Trace:
System.ArgumentNullException: Value cannot be null. (Parameter 'key')
ConcurrentDictionary2.ThrowKeyNullException()
ConcurrentDictionary2.TryGetValue(TKey key, TValue& value)
ConcurrentDictionary2.get_Item(TKey key)
AllureStorage.Get[T](String uuid)
AllureLifecycle.UpdateFixture(String uuid, Action1 update)
AllureLifecycle.UpdateFixture(Action1 update)
AllureLifecycle.StopFixture(Action1 beforeStop)
AllureBindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType) line 352
RunnerTestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
TestExecutionEngine.FireEvents(HookType hookType) line 338
TestExecutionEngine.FireScenarioEvents(HookType bindingEvent) line 322
RunnerTestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
TestExecutionEngine.OnScenarioStart() line 199
RunnerTestExecutionEngine.OnScenarioStart()
TestRunner.OnScenarioStart() line 55
LM01InitialCaseFeature.ScenarioStart()
LM01InitialCaseFeature.LM01_01DefaultLM01InitialCase() line 4
StaticOrInstanceMethodExecutor.ExecuteInternal(ITestThreadExecutionContext testThreadExecutionContext)
StaticOrInstanceMethodExecutor.Execute(ITestThreadExecutionContext testThreadExecutionContext)
TestNodeTask.Execute()
The solution to this was to add specflow.json file and set to 'copy if newer' so it copies to the debug folder.
The content of specflow.json was:
{
"stepAssemblies": [
{
"assembly": "Allure.SpecFlowPlugin"
}
]
}
After making this change the tests ran correctly and an Allure report was generated.

selenium not finding firefox - using teststack.seleno

My selenium tests are all failing on initalisation with this error.
{"The system cannot find the file specified"}
My initialisation code is really simple:
public static class Host
{
private static readonly SelenoHost SelenoHost = new SelenoHost();
static Host()
{
Instance.Run(
configure => configure
.UsingLoggerFactory(new ConsoleFactory())
.WithWebServer(new InternetWebServer("http://localhost:9000/")));
Instance.Application.Browser.Manage().Window.Size = new Size(1500, 1000);
}
public static SelenoHost Instance => SelenoHost;
}
}
Firefox is installed in the default location, (C:\Program Files (x86)\Mozilla Firefox\firefox.exe) and is updated to the latest version (42).
I am using Windows 10 Operating System.
I am using studio 2015.1
If it helps, this is the stack trace.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at OpenQA.Selenium.Firefox.Internal.Executable.LocateFirefoxBinaryFromPlatform()
at OpenQA.Selenium.Firefox.Internal.Executable..ctor(String userSpecifiedBinaryPath)
at OpenQA.Selenium.Firefox.FirefoxBinary..ctor(String pathToFirefoxBinary)
at TestStack.Seleno.Configuration.BrowserFactory.<FireFox>b__b() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\BrowserFactory.cs:line 73
at TestStack.Seleno.Configuration.WebDriverBuilder`1.CreateWebDriver() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\WebDriverBuilder.cs:line 88
at TestStack.Seleno.Configuration.BrowserFactory.FireFox() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\BrowserFactory.cs:line 73
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
I have discovered that this is possibly a bug.
I have discovered that supplying a WebDriver, and default Profile seems to alleviate the problem.
This solution allows a single instance of Firefox to run. If an existing instance is present (open) then a different error is thrown when creating the driver.
An exception of type 'OpenQA.Selenium.WebDriverException' occurred in
WebDriver.dll but was not handled in user code
Additional information:
Unable to bind to locking port 7054 within 45000 milliseconds
As long as you make sure all firefox instances are closed prior to running the tests, this code works:
Instance.Run(
configure => configure
.WithRemoteWebDriver(
() => new FirefoxDriver(
new FirefoxBinary(#"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"),
new FirefoxProfile()))
.UsingLoggerFactory(new ConsoleFactory())
.WithWebServer(new InternetWebServer("http://localhost:9000/")));

Unknown name ComException on a referenced dll in a C# project

I'm writting a C# application which use one of the dll written in C++ as reference. I can use that dll namespace and my project compiles fine. However when I run it I keep getting error in one of the line where I assign a property its value. The exception error I got was the following:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
2013-06-03 12:26:32 - Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))
2013-06-03 12:26:32 - at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
2013-06-03 12:26:32 - at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
2013-06-03 12:26:32 - at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
2013-06-03 12:26:32 - at sstObjTapLib._DsstObjTap.set_CapCode(String )
2013-06-03 12:26:32 - at hpOutput.CTapPagerCom.MessageLoop() in c:\shs\Arial 8.1\XmarkClient\hpOutput\CTapPagerCom.cs:line 225
I initiated the dll object using the following code:
m_ctlTap = new sstObjTapLib.ctlTap();
Below are the three screenshots:
The properties of the DLL I use
The object browser of the dll I use
A breakpoint that shows where the exception occurs.
Looking at the stack error above, it seems that .NET is trying to call some method that does not exist, but I'm just setting a property value. Can somebody point me in the right direction or what I might have missed?
A noted point: While in debugging, I'm looking at my loaded module view, however I don't see this dll name one in the list of my loaded module.
I'm not sure why but the computer I worked with had this same dll installed. I know this by viewing it using the third party tool called RegDllView .
So I went in, unregister the dll I was using, verify it is also gone from the registry and then re-register it again. Clean out my project and recompile everything, and got the exact code to work.
Looking at what I did I think for some reason the application did not recognize the GUID supplied to point to the proper COM.

EventStore & RavenDB Persistence JsonReaderException

Trying to wire up JOliver's EventStore with RavenDB and hit a snag.
I created a new DB in Raven called RavenEventStore.
The following is my wireup;
return Wireup.Init()
.UsingRavenPersistence("RavenEventStore")
.UsingAsynchronousDispatchScheduler()
.DispatchTo(new DelegateMessageDispatcher(DispatchCommit))
.Build();
When the Wireup.Init() is called, this exception is occuring on the RavenDb side;
Url: "/indexes/RavenCommitByDate" Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Line 1, position 1.
at Newtonsoft.Json.JsonTextReader.ParseValue(Char currentChar) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 699
at Newtonsoft.Json.JsonTextReader.ReadInternal() in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 499
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, Type t, JsonConverter propertyConverter) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1072
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 118
at Raven.Database.Extensions.HttpExtensions.ReadJsonObject[T](IHttpContext context) in c:\Builds\raven\Raven.Database\Extensions\HttpExtensions.cs:line 57
at Raven.Database.Server.Responders.Index.Put(IHttpContext context, String index) in c:\Builds\raven\Raven.Database\Server\Responders\Index.cs:line 64
at Raven.Database.Server.Responders.Index.Respond(IHttpContext context) in c:\Builds\raven\Raven.Database\Server\Responders\Index.cs:line 49
at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\raven\Raven.Database\Server\HttpServer.cs:line 477
at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\raven\Raven.Database\Server\HttpServer.cs:line 259
I can see the exception in the RavenDB log as well;
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: . Line 1, position 1. at Newtonsoft.Json.JsonTextReader.ParseValue(Char currentChar) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 699 at Newtonsoft.Json.JsonTextReader.ReadInternal() in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\JsonTextReader.cs:line 499 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, Type t, JsonConverter propertyConverter) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1072 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 118 at Raven.Database.Extensions.HttpExtensions.ReadJsonObject[T](IHttpContext context) in c:\Builds\raven\Raven.Database\Extensions\HttpExtensions.cs:line 57 at Raven.Database.Server.Responders.Index.Put(IHttpContext context, String index) in c:\Builds\raven\Raven.Database\Server\Responders\Index.cs:line 64 at Raven.Database.Server.Responders.Index.Respond(IHttpContext context) in c:\Builds\raven\Raven.Database\Server\Responders\Index.cs:line 49 at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\raven\Raven.Database\Server\HttpServer.cs:line 477 at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\raven\Raven.Database\Server\HttpServer.cs:line 259
I have attempted to eliminate all possibilities by removing the UsingAsynchronousDispatchScheduler() method as well and incur the same error.
The code I am using is strictly from the Example located here:
https://github.com/joliver/EventStore/blob/master/doc/EventStore.Example/MainProgram.cs
Has anyone experienced this? Have failed to find anything on Google as well.
Ryan,
You are using an older server (pre 888) with a new client (888 or later)
Your problem may be similar to this one:
EventStore + RavenDB, not deserializing correct
Also, I would definitely recommend using a custom build against Raven build 888 (or later) as Oren has suggested until I can get a new release out against a newer version of Raven.

Categories