简体   繁体   中英

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') ConcurrentDictionary 2.ThrowKeyNullException() ConcurrentDictionary 2.TryGetValue(TKey key, TValue& value) ConcurrentDictionary 2.get_Item(TKey key) AllureStorage.Get[T](String uuid) AllureLifecycle.UpdateFixture(String uuid, Action 1 update) AllureLifecycle.UpdateFixture(Action 1 update) AllureLifecycle.StopFixture(Action 1 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 RunnerT estExecutionEngine.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM