javascript 如何一次运行多个量角器测试套件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32100063/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 14:51:35  来源:igfitidea点击:

How do I Run multiple protractor test suites at once?

javascriptangularjsprotractor

提问by jparry

First attempt at using Protractor. I would like to be able to run multiple suites in succession. I have an application that is one big angular form with different scenarios. I have expected results for each scenario and would like to enter one command and run through each test. I thought I could just use comma separated like:

第一次尝试使用量角器。我希望能够连续运行多个套件。我有一个应用程序,它是一个具有不同场景的大角度形式。我对每个场景都有预期的结果,并想输入一个命令并运行每个测试。我以为我可以使用逗号分隔,例如:

protractor config.js --suite=rf1_breast, rf1_ovarian, rf1_pancreatic

But I am getting the error:

但我收到错误:

Error: more than one config file specified

错误:指定了多个配置文件

Which is strange as there is only the one config file which is in the directory where I am running protractor.

这很奇怪,因为在我运行量角器的目录中只有一个配置文件。

Here is my config.js:

这是我的config.js

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  capabilities: { 'browserName': 'chrome' },
  framework: 'jasmine2',
  suites: {
    rf1_breast: './rf1-ashkenazi-hboc/Breast/specs/*_spec.js',
    rf1_ovarian: './rf1-ashkenazi-hboc/Ovarian/specs/*_spec.js',
    rf1_bladder_fail: './rf1-ashkenazi-hboc/Bladder-expected-fail/specs/*_spec.js',
    rf1_pancreatic: './rf1-ashkenazi-hboc/Pancreatic/specs/*_spec.js',
    rf1_prostate: './rf1-ashkenazi-hboc/Prostate/specs/*_spec.js'
  },
  onPrepare: function() {
    /* global angular: false, browser: false, jasmine: false */
    browser.manage().window().setSize(1600, 1600);
    // Disable animations so e2e tests run more quickly
    var disableNgAnimate = function() {
      angular.module('disableNgAnimate', []).run(['$animate', function($animate) {
        $animate.enabled(false);
      }]);
    };

    browser.addMockModule('disableNgAnimate', disableNgAnimate);
},
  jasmineNodeOpts: { showColors: true }
};

Is there a better way around getting each scenario run?

有没有更好的方法来运行每个场景?

回答by alecxe

Don't put spaces after commas:

逗号后不要加空格:

protractor config.js --suite rf1_breast,rf1_ovarian,rf1_pancreatic

回答by dragos

Try to make your suite composed by multiple files. I Have a line for the test I currently work on and another with the entire suite of tests:

尝试让您的套件由多个文件组成。我有一条线路用于我目前正在进行的测试,另一条线路用于整个测试套件:

exports.config = { allScriptsTimeout: 11000, specs: [ './e2e/**/1.Landing.Page.ts', './e2e/**/2.Confirmation.Page.ts', './e2e/**/3.PersonalData.Page.ts', './e2e/**/4.sms.Page.ts', './e2e/**/5.idCard.Page.ts' ], }

exports.config = { allScriptsTimeout: 11000, specs: [ './e2e/**/1.Landing.Page.ts', './e2e/**/2.Confirmation.Page.ts', './e2e/**/3.PersonalData.Page.ts', './e2e/**/4.sms.Page.ts', './e2e/**/5.idCard.Page.ts' ], }

This works for me.

这对我有用。

回答by Sameera De Silva

In your config.js

在你的 config.js

If you want to run the script as a suite comment out the spec line

如果要将脚本作为套件运行,请注释掉规范行

// specs: ['src/com/sam/scriptjs/alertexamplespec.js']

give the suite name and location

提供套房名称和位置

 suites: {
      //Suite name and location give * to run all the specs or provide the name 
        smoke: ['./smoke/*.spec.js'],
        endtoend: ['src/com/sam/scriptjs/*.spec.js'],
//Futhermore you can select few test specs
testfew: ['./smoke/editorder.spec.js','./smoke/cancelorder.spec.js']

},  

then in cmd type protractor filenameconfig.js

然后在 cmd 中输入 protractor filenameconfig.js