【发布时间】:2019-06-03 22:57:01
【问题描述】:
我又有问题了……
我尝试从 Azure DevOps 中的持续集成测试中制作测试报告。我编写了单元测试,如下所述:
https://code.visualstudio.com/api/working-with-extensions/testing-extension
我写的 yml 主要是这样描述的:
https://code.visualstudio.com/api/working-with-extensions/continuous-integration
现在我想“发布”我的测试结果... 我认为要发布它们,我必须以以下格式之一创建 XML(或 TRX):JUnit、NUnit 2、NUnit 3、Visual Studio Test (TRX) 和 xUnit 2。 似乎我受限于如何创建记者/测试运行者或其他任何东西......我不明白。
vscode提供的API如下:
testRunner.configure({
ui: "tdd",
useColors: true
});
module.exports = testRunner;
API 的预期类型是:
interface MochaSetupOptions {
//milliseconds to wait before considering a test slow
slow?: number;
// timeout in milliseconds
timeout?: number;
// ui name "bdd", "tdd", "exports" etc
ui?: string;
//array of accepted globals
globals?: any[];
// reporter instance (function or string), defaults to `mocha.reporters.Dot`
reporter?: any;
// bail on the first test failure
bail?: boolean;
// ignore global leaks
ignoreLeaks?: boolean;
// grep string or regexp to filter tests with
grep?: any;
// colored output from test results
useColors?: boolean;
// causes test marked with only to fail the suite
forbidOnly?: boolean;
}
我认为我最好的尝试是使用该模块 https://www.npmjs.com/package/mocha-junit-reporter:
testRunner.configure({
reporter: 'mocha-junit-reporter',
reporterOptions: {
mochaFile: './path_to_your/file.xml'
}
});
我知道它不符合所描述的 API,但是当您查看 vscode-module 的源代码时:
function configure(opts) {
mocha = new Mocha(opts);
}
exports.configure = configure;
所以它符合“mocha-junit-reporter”模块的文档
【问题讨论】:
-
你发现了吗?我在为 vscode 单元测试生成结果时遇到了同样的问题。
标签: visual-studio-code mocha.js vscode-extensions test-runner