【问题标题】:How to see what Protractor tests is currently executing?如何查看 Protractor 测试当前正在执行什么?
【发布时间】:2014-03-06 12:09:15
【问题描述】:

在我的量角器测试脚本中,我使用通常的符号:

describe("mytest") {
    ...
    it(" should do this") {
    ... 
    it(" should do that") {

我希望在我运行它们时能够查看当前正在运行的测试以及每个测试的哪个部分。我可以使用任何选项将测试描述输出到控制台吗?

【问题讨论】:

    标签: jasmine protractor


    【解决方案1】:
    【解决方案2】:

    您可以使用 --verbose 选项打印有关您的测试的更多信息,但它不会告诉您当前正在运行哪个测试。

    如果您想要该功能,我建议您创建一个问题。 https://github.com/angular/protractor/issues/new

    $ ./node_modules/protractor/bin/protractor protractor-config.js --verbose
    
    ------------------------------------
    PID: 7985 (capability: chrome #1)
    ------------------------------------
    
    Using the selenium server at http://localhost:4444/wd/hub
    
    angularjs homepage
        should greet the named user
    
        todo list
            should list todos
            should add a todo
    
    Finished in 5.915 seconds
    3 tests, 5 assertions, 0 failures
    

    【讨论】:

    • 也可以将其设置到 protractor-config.js 中:jasmineNodeOpts: {isVerbose: true} ;)
    【解决方案3】:

    由于量角器在节点中运行,您可以像在 javascript 中一样使用 console.log,更多控制台乐趣请参见节点 docs

    我喜欢在功能之后放置任何日志,以便我知道它已完成,因此将其包装在 .then() 函数中似乎最适合我

    示例:

    element(elementToFind).click().then(function(){
        console.log("clicked element");
        continue();
    });
    

    【讨论】:

    • 谢谢。我知道我可以使用 console.log,但我需要动态获取测试名称,否则我将不得不为每个测试手动添加它。
    【解决方案4】:

    如果您需要知道当前运行的规范名称,您可以使用:jasmine.getEnv().currentSpec.description 并记录下来

    【讨论】:

      【解决方案5】:
              console.log('\nTest spec: ' + __filename + '\n');
      

      记录测试但不知道如何记录正在执行的

      【讨论】:

      • ReferenceError: __filename is not defined
      猜你喜欢
      • 1970-01-01
      • 2010-09-07
      • 1970-01-01
      • 2017-06-19
      • 1970-01-01
      • 2017-01-26
      • 1970-01-01
      • 2016-08-21
      • 1970-01-01
      相关资源
      最近更新 更多