Testing 如何使用开源testcafe编写参数化测试?
我发现了很多用于测试咖啡馆的语法,但是语法与我使用的完全不同。我猜他们是为了停产的付费版本。我怎样才能对免费版本做同样的事情?我不是专门寻找用户角色,我希望编写带有参数的测试。您想这样做吗? 这对我很管用Testing 如何使用开源testcafe编写参数化测试?,testing,e2e-testing,testcase,testcafe,parameterized-tests,Testing,E2e Testing,Testcase,Testcafe,Parameterized Tests,我发现了很多用于测试咖啡馆的语法,但是语法与我使用的完全不同。我猜他们是为了停产的付费版本。我怎样才能对免费版本做同样的事情?我不是专门寻找用户角色,我希望编写带有参数的测试。您想这样做吗? 这对我很管用 import { Selector } from 'testcafe'; fixture `Your fixture` .page `http://some_url.com` const testCases = [ { name: 'name1', param: 'param1'
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)
});
}
使用JS和YAML的组合可以添加额外的扭曲
import YamlTableReader, {fixtureData, TestData} from "./YamlTableReader";
var table = fixtureData `
| ID | N1 | N2 | Equals |
| Should Be equal | 1 | 1 | true |
| Shouldn't be equal | 1 | 2 | false |
| Shouldn't be equal | 1 | "hans" | false |
| Should be equal | hans | "hans" | true |
`;
table.forEach(row => {
test('Should be equal', t => {
row["Equals"] == (row["N1"] === row["N2"]));
}
});
这个问题的简单来源可以在这里找到问题是关于testcafe而不是jasmine