有没有办法让Protractor Cucumber仅重新运行失败的浏览器测试?

时间:2019-05-24 22:46:48

标签: angular automation protractor

我正在使用量角器薄片,并使用硒网格并行运行浏览器测试。如果其中一个浏览器失败,我不想重新运行所有浏览器测试。

是否可以在配置中设置为仅重新运行失败的浏览器? 量角器配置文件

exports.config = {
        seleniumAddress: 'http://localhost:4444/wd/hub',
        getPageTimeout: 600000,
        allScriptsTimeout: 500000,
        defaultTimeoutInterval: 30000,
        framework: 'custom',
        // path relative to the current config file
        frameworkPath: require.resolve('protractor-cucumber-framework'),
        multiCapabilities:
        [{
          'browserName': 'chrome',
          specs: 'features/chrome/*.feature'
        },
        {
          'browserName': 'firefox',
          specs: 'features/firefox/*.feature'
        }],
        baseUrl: 'https://localhost:8080',
        ignoreSynchronization: true,
        cucumberOpts: {
          strict: true,
          require: [
            'hooks/hooks.js',
            'specs/*Spec.js'
          ],
          tags: [
            "@runThis", 
            "~@ignoreThis"
          ],
          profile: false,
          format: 'json:e2e/reports/cucumber-report.json',
          resultJsonOutputFile: 'e2e/reports/cucumber-report.json'
        },
        onPrepare: async function() {

          const fs = require('fs');
          const path = require('path');

          const directory = 'e2e/reports';

          //cleans up the json results from the previous build when using node flake
          fs.readdir(directory, (err, files) => {
            if (err) throw err;

            for (const file of files) {
              fs.unlink(path.join(directory, file), err => {
                if (err) throw err;
              });
            }
          });

          var chai = require('chai');
          chai.use(require('chai-as-promised'));
          global.expect = chai.expect;
          browser.ignoreSynchronization = true;
          await browser.manage().window().maximize();
          browser.waitForAngular();           
          browser.manage().timeouts().implicitlyWait(30000); 

        },
        onComplete: function() {

        }
    }

1 个答案:

答案 0 :(得分:0)

是的,为此,您需要使用要提供给输出的文件名重新运行报告器:

format: ['pretty', 'rerun:@rerun.txt']

然后,您必须运行带有黄瓜选项并指定文件名的量角器:

protractor test/cucumber/conf/cucumber1Conf.js --cucumberOpts.rerun test/cucumber/@rerun.txt

有关它的更多信息,请参见:https://github.com/protractor-cucumber-framework/protractor-cucumber-framework/issues/89