microsoft / vso-agent

Visual Studio Team Services and TFS agent for Mac OSX and Linux
MIT License
132 stars 57 forks source link

TestResultReader does not work with empty suites. #253

Closed darthtrevino closed 8 years ago

darthtrevino commented 8 years ago

Hello, I'm trying to use the "Report Test Results" step in VSO on a NodeJS project, but I'm running into a few issues. I'm running my tests via Mocha. I've tried both the built-in xunit reporter and a third party junit reporter. The xunit reporter could not find the 'assemblies' node in the XML, which I'm assuming is an extension of the xunit schema you guys expect for .net projects.

The JUnit reporter creates an empty root suite, which caused an error in TestResultReader.ts, where a suite could not iterate its tests. I was able to work around the empty root suite, but this error also showed up when I had nested mocha structures like this:

describe("Some Component", () => {
    describe("some aspect", () => {
        it("<specific test>", () => {
        });
        ...
    });
});

So, in the end, if a suite doesn't contain any tests, you should just skip it. e.g. wrap this (https://github.com/Microsoft/vso-agent/blob/master/src/agent/testresultreader.ts#L261) with if (rootNode.testcase) {}.

If I get some time later this week, I'll put together a PR for this issue.