【问题标题】:Analysing SpecFlow duration metrics分析 SpecFlow 持续时间指标
【发布时间】:2021-08-31 02:14:21
【问题描述】:

我有一些 SpecFlow 测试提供如下测试输出:

Given my location is set to secret
-> done: Location.GivenMyLocationIsSetTo("secret") (0.0s)
And the date today is 03 Jun 2017 15:00
-> done: Date.GiveThatTheEffectiveDateIs(2017-06-03 3:00:0...) (0.0s)
And I have selected a client with the following properties
  --- table step argument ---
  | property                  | value      |
  | SomeAttr                  | someval    |
  | SomeAttr2                 | someval2   |
-> done: Client.GivenIHaveSelectedAClientWithTheFollowingProperties(<table>) (0.0s)
And I select a currency of CAD
-> done: Currency.WhenISetCurrency("CAD") (0.0s)
Then I see the following messages
  --- table step argument ---
  | classification | message       |
  | Class1         | Hello world   |
-> done: Message.ThenISeeTheFollowingMessages(<table>) (2.9s)

我注意到,对于我的 所有 测试,最后一步是需要所有时间的步骤(即上面的 2.9 秒 - 见底线 - 所有之前的步骤加起来为零)。

我有成千上万个测试用例,它们需要很多小时才能运行,这已成为一个问题。

  • 这是正常现象还是意料之中?
  • 此持续时间指标是否包括测试工具本身的拆解(或者它纯粹是待测代码)?
  • 关于如何分析持续时间并进一步分解它有什么提示吗?

注意:

  • 我没有使用 Selenium
  • 整个测试需要 2.9 秒 - 其中 100% 似乎在最后一步

【问题讨论】:

  • 您是否使用 Selenium 来自动化浏览器?能否为最后一步的步骤定义添加代码?
  • 对于这个特定的测试,测试花费的总时间是多少?这应该可以帮助您回答测试的拆卸是否包含在最后一步中。

标签: c# testing specflow


【解决方案1】:

在该步骤中获得指标的最接近方法是在调试模式下单步执行代码。

我发现我可以在.feature 文件中放置断点,Visual Studio 会在那里中断。还能够使用常用方法在我的代码中放置断点。 Visual Studio PerfTips help 指出代码的慢部分。

【讨论】:

    猜你喜欢
    • 2021-12-11
    • 2021-12-12
    • 1970-01-01
    • 2019-04-24
    • 1970-01-01
    • 2014-07-16
    • 1970-01-01
    • 2014-01-05
    • 1970-01-01
    相关资源
    最近更新 更多