I have a problem, again...
I try to make a test report from my continuous integration tests in Azure DevOps. I have written unit tests as described in:
https://code.visualstudio.com/api/working-with-extensions/testing-extension
I have written yml mostly as described here:
https://code.visualstudio.com/api/working-with-extensions/continuous-integration
Now I want to "publish" my test results... I think to publish them, I have to create an XML(or TRX) in one of the following formats: JUnit, NUnit 2, NUnit 3, Visual Studio Test (TRX) and xUnit 2. It seems I am limited how to create a reporter/testrunner or whatever... I don't get it.
The provided API of vscode looks like:
testRunner.configure({
ui: "tdd",
useColors: true
});
module.exports = testRunner;
The expected type for the API is:
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;
}
I think my best try was using that module https://www.npmjs.com/package/mocha-junit-reporter:
testRunner.configure({
reporter: 'mocha-junit-reporter',
reporterOptions: {
mochaFile: './path_to_your/file.xml'
}
});
I know it fits not the API as described, but when you have a look at the source code from the vscode-module:
function configure(opts) {
mocha = new Mocha(opts);
}
exports.configure = configure;
So it fits the documentation of the "mocha-junit-reporter" module
let a: any = {
ui: "tdd",
reporter: "xunit",
reporterOptions: {
output: normalize(join(getExtensionRootPath(), "..", "TestResults", "unit-tests", os + ".xml")),
}
};
testRunner.configure(a);
this did it for me except for Linux I will edit this answer if get managed it for Linux too.