有没有办法在 TestCafe 中指定动态报告文件名
Is there a way to specify a dynamic report filename in TestCafe
我正在将 TestCafe 的输出写入文件。想知道能不能像截图路径那样做个动态路径
我尝试使用类似于此处列出的值,但我认为这仅适用于屏幕截图和视频。
这是有效的,但不是动态的:
testcafe chrome test.testcafe -r json:report.json
这是我想做的事情:
testcafe chrome test.testcafe -r json:T:\Logs\ -p ${DATE}/${TIME}/${FIXTURE}/${TEST}/${FILE_INDEX}.json
编辑 1:应该这么说,但我正在使用 TestCafe Studio。我可以使用内置的 Function 操作,但我受限于 Studio 的有限功能。
我建议你使用 programming interface to customize your reporter 输出:
run.js:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
const config = { key1: 'value1', key2: 'value2' }; // you can specify it as a date, etc.
return runner
.src(['d:/***/test.js'])
.browsers(['chrome'])
.reporter('xunit', `reports/${config.key1}/out-${config.key2}.xml`)
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
命令:
node run.js
目前,TestCafe Studio 不允许自定义报告名称。我们会考虑您对我们未来版本的建议。
作为解决方法,我建议您查看 Export the Report 功能
我正在将 TestCafe 的输出写入文件。想知道能不能像截图路径那样做个动态路径
我尝试使用类似于此处列出的值,但我认为这仅适用于屏幕截图和视频。
这是有效的,但不是动态的:
testcafe chrome test.testcafe -r json:report.json
这是我想做的事情:
testcafe chrome test.testcafe -r json:T:\Logs\ -p ${DATE}/${TIME}/${FIXTURE}/${TEST}/${FILE_INDEX}.json
编辑 1:应该这么说,但我正在使用 TestCafe Studio。我可以使用内置的 Function 操作,但我受限于 Studio 的有限功能。
我建议你使用 programming interface to customize your reporter 输出:
run.js:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc;
const runner = testcafe.createRunner();
const config = { key1: 'value1', key2: 'value2' }; // you can specify it as a date, etc.
return runner
.src(['d:/***/test.js'])
.browsers(['chrome'])
.reporter('xunit', `reports/${config.key1}/out-${config.key2}.xml`)
.run();
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount);
testcafe.close();
});
命令:
node run.js
目前,TestCafe Studio 不允许自定义报告名称。我们会考虑您对我们未来版本的建议。
作为解决方法,我建议您查看 Export the Report 功能