Jasmine 多次运行spec

Jasmine 多次运行spec,jasmine,protractor,Jasmine,Protractor,上面是我的配置文件,我想运行recovery suite以确保系统恢复。所以基本上相同的测试X次。 不知什么原因,它只运行一次。 是否有任何设置可以避免它并让它多次运行 suites: { dev: ['./test/show-file.spec.js'], smoke: [ // './test/template.spec.js', './test/form-validation.spec.js', './test/upl

上面是我的配置文件,我想运行recovery suite以确保系统恢复。所以基本上相同的测试X次。 不知什么原因,它只运行一次。 是否有任何设置可以避免它并让它多次运行

    suites: {
    dev: ['./test/show-file.spec.js'],
    smoke: [
        // './test/template.spec.js',
        './test/form-validation.spec.js',
        './test/upload.spec.js',
        './test/empty-folder.spec.js',
        './test/versions.spec.js',
        './test/search.spec.js',
        './test/archive.spec.js',
        './test/move.spec.js',
        './test/copy.spec.js',
        './test/tags.spec.js',
        './test/share.spec.js',
        // './test/signup.spec.js',
        // './test/show-file.spec.js',
    ],
    recovery: [
        './test/show-file.spec.js',
        './test/show-file.spec.js',
        './test/show-file.spec.js',
        './test/show-file.spec.js',
        './test/show-file.spec.js',
        './test/show-file.spec.js',
    ]
},
找到一份工作

test.conf.js --suite=recovery 
for(变量i=0;i<10;++i){
描述('Suite:show',函数(){
它('可能很好',功能(){
expect(Math.random()<0.5).toBeTruthy();
});
});
}

量角器将在
套件
上执行重复性检查,以删除相同的文件模式/文件名,但在
规格
上不执行此操作

简单的解决方案是使用
specs
而不是
suite
。不需要额外的脚本

复杂的解决方案需要额外的脚本帮助

//量角器配置js

for (var i = 0; i < 10; ++i){
    describe('Suite: show', function () {
        it('may be fine', function () {
            expect(Math.random() < 0.5).toBeTruthy();
        });
    });
}
//量角器命令行:
量角器conf.js--repeat.suites=“冒烟,恢复”--repeat.times=2


注意您可以继续使用其他量角器支持的cli选项。只有当您想重复执行某个套件时,才不应使用
--suite
,而应使用
--repeat.suite

事件规范不允许多次使用相同的文件名。
var params = {};   
process.argv.slice(3).forEach(function(arg, index) {
    var flag = arg.split('=')[0];
    var value = arg.split('=')[1];
    var name = flag.replace('--', '');   
    params[name] = value;   
});

console.dir(params);

var config = {   
    capabilities: {
        browserName: 'chrome'
    },   
    suites: {
        dev: ['./test/show-file.spec.js'],
        smoke: [
            './test/template.spec.js',
            // ...
        ],
        recovery: [
            './test/show-file.spec.js'
        ]
    },   
    onPrepare: function() {}, 
    // ...
};

if (params['repeat.suites'] && config.suites &&
    Object.keys(config.suites).length > 0) {

    var repeat = (params['repeat.times'] || 1) * 1;
    var specs = [];   
    params['repeat.suites'].split(',').forEach(function(suiteName) {
        suiteName = suiteName.trim();
        if (config.suites[suiteName]) {
            specs = specs.concat(config.suites[suiteName]);
        }
    });

    var allSpecs = [];   
    while (repeat > 0) {
        allSpecs = allSpecs.concat(specs);
        repeat--;
    }  
    config.specs = allSpecs;
}

console.dir(config);   
exports.config = config;