无法在c# specflow .net Core中生成Allure报告。值不能为空。(参数'key')值不能为空。OnScenarioStart()。

问题描述 投票:0回答:1

我在.netcore 3.1上写了一个使用Specflow和Specrun的C#测试自动化框架。

我可以用Specrun运行测试并得到一个报告,但是我想得到一个Allure报告。

所以我安装了Specflow.Allure。我有一个AllureConfig.json。

我希望我现在可以直接运行测试并获得Allure报告。

然而,它似乎不是那么简单。

当我试着运行测试时,如果失败了,就会出现下面的消息。

有人知道我做错了什么吗?我是否需要添加更多的代码来获得Allure报告?

消息:值不能为空。 值不能为空。(参数'key')堆栈跟踪。 System.ArgumentNullException.Value不能为空。Value cannot be null.(参数'key')堆栈跟踪:System.ArgumentNullException: Value cannot be null. (参数'key')ConcurrentDictionary。2.ThrowKeyNullException() ConcurrentDictionary2.TryGetValue(TKey key, TValue& value) ConcurrentDictionary2.get_Item(TKey key) AllureStorage.Get[T](String uuid) AllureLifecycle.UpdateFixture(String uuid, Action1更新)AllureLifecycle.UpdateFixture(Action)1 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) 第352行 RunnerTestExecutionEngine. InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType) TestExecutionEngine.FireEvents(HookType hookType) 第338行 TestExecutionEngine.FireScenarioEvents(HookType bindingEvent) 第322行 RunnerTestExecutionEngine. FireScenarioEvents(HookType bindingEvent) TestExecutionEngine.OnScenarioStart() 第199行 RunnerTestExecutionEngine.OnScenarioStart() TestRunner.OnScenarioStart() 第55行 LM01InitialCaseFeature.ScenarioStart() LM01InitialCaseFeature. LM01_01DefaultLM01InitialCase() 第4行 StaticOrInstanceMethodExecutor.ExecuteInternal(ITestThreadExecutionContext testThreadExecutionContext) StaticOrInstanceMethodExecutor.Execute(ITestThreadExecutionContext testThreadExecutionContext) TestNodeTask.Execute()

c# specflow allure specrun
1个回答
0
投票

解决这个问题的方法是添加specflow.json文件,并设置为'copy if newer',这样它就会复制到debug文件夹中。

specflow.json的内容是。

{
  "stepAssemblies": [
    {
      "assembly": "Allure.SpecFlowPlugin"
    }
  ]
}

在做了这个改变后,测试正常运行,并生成了Allure报告。

© www.soinside.com 2019 - 2024. All rights reserved.