【问题标题】:Is there a way to log the duration of time of the before and after methods in a Protractor/Jasmine specification?有没有办法在量角器/茉莉花规范中记录前后方法的持续时间?
【发布时间】:2017-11-03 09:26:23
【问题描述】:

我的量角器执行的输出如下:

[13:51:55] I/launcher - Running 1 instances of WebDriver
[13:51:55] I/direct - Using ChromeDriver directly...
Spec started
[2017-10-31 13:51:59.710] [DEBUG] protractorLog4js - [spec mapper app]: Before All
[2017-10-31 13:51:59.712] [INFO] protractorLog4js - [LoginLogoutWorkflow]: Using default username and password to login.

  [2017-10-31 13:52:50.406] - spec mapper app

    [2017-10-31 13:52:50.407] - import/export page
      [2017-10-31 13:52:50.407] - √ TC2963: ImportComponentGrid_ShouldDefaultSortBySubmittedDateInDescendingOrder_WhenPageIsLoaded (16 secs)
      [2017-10-31 13:53:03.140] - √ TC2955: ImportComponentAddButton_ShouldImportDoorScheduleData_WhenValidExcelFileIsUsed (13 secs)

Executed 2 of 2 specs SUCCESS in 1 min 3 secs.
[13:53:03] I/launcher - 0 instance(s) of WebDriver still running
[13:53:03] I/launcher - chrome #01 passed

我看到执行的总时间为1 min 3 seconds,但测试本身分别只需要 16 秒和 13 秒。如果我减去测试时间,我最终还剩 34 秒。我有 beforeAllbeforeEachafterAll 方法,我认为这些方法会占用剩下的时间。

我想找到一种配置,允许对这些设置和拆卸方法进行输出和时间跟踪。我目前正在使用 Protractor、jasmine-spec-reporter 和 log4js-protractor-appender 来生成上面的输出。我已经通过量角器和 jasmine-spec-reporter 的配置来尝试为这些类型的方法找到一个选项,但我没有太多运气找到我正在寻找的东西。感谢您提出的任何想法!

【问题讨论】:

    标签: javascript jasmine protractor


    【解决方案1】:

    您可以实现自己的函数来为所需的操作计时。

    startTime = new Date().getTime();
    // any operations or function code which you want to measure
    var endTime = new Date().getTime();
    var elapsedTime = endTime - startTime;
    console.log('elapsedTime = ' + elapsedTime + 'ms');
    

    【讨论】:

      猜你喜欢
      • 2020-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      相关资源
      最近更新 更多