如何使用开源testcafe编写参数化测试?

时间:2018-06-07 08:02:03

标签: testcase testcafe parameterized-tests

我为测试咖啡馆找到了很多introductions to parameterized tests/ test cases,但语法与我正在使用的语法完全不同。我猜他们已经停止使用付费版本了。如何使用免费版本做同样的事情?我没有专门寻找用户角色,我想用一般的参数编写测试。

2 个答案:

答案 0 :(得分:1)

你想做这样的事吗? 这对我很有用

import { Selector } from 'testcafe';

fixture `Your fixture`
.page `http://some_url.com`

const testCases = [ 
    { name: 'name1', param: 'param1' },
    { name: 'name2', param: 'param2' }
    ...
];

for (const c of testCases) {
    test(`Test ${c.name}`, async t => {
        yourTestMethod(c.param)
    });
}

答案 1 :(得分:1)

可以通过结合使用JS和YAML来添加其他功能

https://www.google.com/maps/search/?api=1&query=49.258786662320986,-123.0241870880127

有关此问题的简单来源,请点击https://github.com/deicongmbh/jasmine-param-tests