empty xml files throw exception

empty xml files throw exception

Hi there,

I am using NCover 3.0 in an automated process. Sometimes we get coverage files after a NCover run which are empty (why I not yet figured out) while others are not. In our process the files are processed by NCover.Reporting to get an xml file for some values. As some files are empty the following exception is thrown (we try to process at this point only one empty xml file):

NCover Reporting Complete v3.0.18 x86 (Administrator) Merging and Reporting for NCover Copyright (c) 2007 - 2009 Gnoso Inc. http://www.ncover.com

-- Top-level exception (System.Exception) An error occurred while loading your coverage file: The Xml Document is not valid. -- Stack Trace at NCover.Framework.Reports.ReportingProcessor.CreateCoverageView(List1 filenames) at NCover.Framework.Reports.ReportingProcessor.Process() at NCover.Reporting.ReportMain.Main(String[] args) -- Inner exceptions The Xml Document is not valid. -- Stack Trace at NCover.Framework.Utilities.CoverageLoader.LoadModel(Stream stream, Stream trendData, NCoverExportVersion forcedVersion, Boolean force) at NCover.Framework.Utilities.CoverageLoader.Load(Stream stream, Stream trendData, NCoverExportVersion forcedVersion, Boolean force) at NCover.Framework.Utilities.CoverageLoader.Load(String path, NCoverExportVersion forcedVersion, Boolean force) at NCover.Framework.Reports.ReportingProcessor.CreateCoverageView(List1 filenames)

Root element is missing. -- Stack Trace at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at System.Xml.XmlReader.MoveToContent() at NCover.Framework.Utilities.NCoverXmlUtilities.GetXmlFileData(Stream stream) at NCover.Framework.Utilities.CoverageLoader.LoadModel(Stream stream, Stream trendData, NCoverExportVersion forcedVersion, Boolean force)

Execution Time: 139 ms

Is this a bug or do I have to check if the coverage files contain anything?

Thanks in advance, Daniela


RE: empty xml files throw exception

The stack trace isn't a bug (although it could be handled more gracefully), but that NCover is producing empty coverage files sometimes and not other times might be. Perhaps you can tell me some more info that will help me track the problem down? What exact version of NCover are you using? 3.0.18, 3.0.20? What sort of application are you covering (IIS, windows service, GUI/Console application)? About how large is the application (# of assemblies, total size of all assemblies)?

I've talked with other members of the NCover team and we've agreed to handle the error more gracefully in a future release. Right now we're planning to check the coverage files to see if they have data before we load them, and if any file doesn't then we'll print a message that shows the file's path, says the file is empty, and then says that no report was created. Do you think that's a reasonable way to handle the error? What do you think should happen if NCover.Reporting.exe is given an empty coverage file?


RE: empty xml files throw exception

I am using NCover version 3.0.18 and I am covering a GUI application written for .Net framework 2.0 with SP. The application contains a huge number of assemblies (a quick view showed me more than 400 dll files), but for the tests I'm only using subsets of the assemblies and then NCover needs to cover between 1 and 20. These assemblies may have a size up to 5 MB and one has currently the size of 12 MB. The next step is to use the inclusion/exclusion mechanism for namespaces to reduce the data to cover for the dll which has 12 MB because the output coverage xml file is 80 MB.

I would suggest to check the coverages files for content and print out the file names of the empty ones, like you suggested. But then I would try to generate a report from the files which have content and not to stop generating a report.

When the error appeared I tried to merge 120 coverage files into one xml file and setting a project name. The arguments were the xml files with their complete path because the files exist in different folders, //s for the new (merged) xml file and //p for setting the project name.


RE: empty xml files throw exception

Quick note: when you do the inclusion/exclusion of namespaces, you need to keep the assemblies that you are including in the include assemblies list, or have an empty include assemblies list or the include/exclude namespace stuff will not work.

When I check the coverage files to see if they are valid, I meant that all the files would be checked before any attempt was made to merge them together, and then a list of all the files that were invalid would be printed. The reason that I didn't want to create a report if any file was invalid was because the report would be incomplete -- it wouldn't have all the data that you expected it to have and unless someone checks the build server log every time NCover.Reporting executes then they would never know that the report was missing data.

Does it make more sense now why I didn't want to create a report if a file was invalid? Why do you think a report should be created anyway?