tags:

views:

35

answers:

4

I have a large acceptance test suite that runs the source application many thousands of times, creating an NCOVER report for each run. After each test, it merges the generated code coverage report into a large "master" coverage report for the whole application.

My worry here is that I'm running into a Shlemiel the Painter problem, as the merge operation is parsing the large coverage file for every test.

I can pass more than one coverage file to NCover.Reporting.Exe, which actually does the merge, but when I try to pass them all at once I'm running into operating system limits on command line length.

Does NCover.Reporting provide some sort of input coverage report listing that I can save to a file, and have it merge all the reports in one go?

+1  A: 

I would merge 25-50 at a time and at the end, take those and merge them together.

May I ask why you are running each test on it's own. Are you using the include feature to only instrument the code you are running or are all of your coverage files very large?

You could also email support, they may have a better option.

joe.feser
@joe: It's being run separately because they are acceptance tests. The actual program under test is actually being run that many times, with different inputs. These are not unit tests.
Billy ONeal
So you are not performing this operation to determine only the code executed by that one test, it is just the nature of your testing framework. When we wrote the merge, we never considered this many coverage files. Have you tried using the config file format? That should have no limit.
joe.feser
@joe: It looks like the input files still need to be specified on the command line even when the config file format is used (based on http://docs.ncover.com/ref/3-0/ncover-reporting/configuration/merging , there doesn't seem to be an XML element for letting NCover know about *input* files)
Billy ONeal
@joe: Merging of ~510 coverage files (each about 20MB) took about 1 hour on our build server.
Billy ONeal
+1  A: 

@joe the trouble is you have to generate the config file. in theory he could do that by writing a little helper program that adds all of the files in a DIRECTORY to the config file, but you'd have to use the directory name without a file filter i.e. do

myhelper.exe coveragedirectory

NOT

myhelper.exe coveragedirectory*.xml

command line length limits are a "feature" of DOS 1.0 and hence of the emulator built into windows. Have you tried using powershell?

Stephen Ward
I don't remember building wildcard support in. I was mainly commenting on not ever considering the use case of 1000+ files in a merge set. I am not even sure how well it will run. I am curious to see the end result and how long it takes. The fact that 1000+ tests are running is awesome. :)ps. good to see you are also following ncover on twitter. :)
joe.feser
@Stephen: Actually, the command line length limits are a limitation of the Windows Kernel, which uses a maximum length string of 32k characters. (Limited by the size of a signed short)
Billy ONeal
+1  A: 

We just updated NCover to handle multiple coverage runs under NCover.Console much more efficiently. Assuming you are running the same application each time I would make sure that you're updated to NCover 3.4.12 and run NCover.Console with the //coverall option on the script that you're using to spawn your application rather than NCover each time you start your app. That will generate one merged XML file that should handle things for you.

Feel free to drop an email to [email protected] and we can help you out with it, if needed. Be sure to mention this url.

commondream
OK, will give that a shot.
Billy ONeal
Actually, this doesn't work because a large part of the test harness is actually running the outputs of our program, which produces .NET Assemblies. :( We would need a way to specify on the fly what is covered, and it doesn't seem to offer this.
Billy ONeal
Would NCover's //pn flag handle that. You give it the name of the executables you want to collect coverage on, and can use multiple //pn flags if you need to cover multiple executables:http://docs.ncover.com/ref/3-0/ncover-console/command-line/profiling-options#pm
commondream
Wow, that last comment wasn't necessarily the clearest of communicating on my part. Forgot to mention in that last comment that //pn will match on subprocesses, so if you're in a more complicated process tree you can run NCover to start the top of the process tree and //pn will cause only the children you want to profile to be profiled.
commondream
Okay, giving //pn a shot now. We'll see how it goes. Thanks :)
Billy ONeal
A: 

Well, what I settled on was kind of like Stephen Ward's answer. I put all the coverage files into a directory and ran NCover.Reporting.exe Path\To\My\Directory\*.xml //s Merged.nccov.

He's not getting the checkmark though because his answer telling me I could not use a wildcard on the commandline is incorrect; in fact, the wildcard is the only way NCover would recognise the XML files in that directory. I think he's used to the Unix world (considering there was some Unix FUD in his answer), where the shell takes responsibility for handling wild cards. The windows shell doesn't attempt to expand wildcards, so we didn't run into length limits with that.

With this solution though, I was able to make our runs about 20% faster than the old merge-after-each-test method, which is good. (Coverage runs are still four times as long as non coverage runs, but we don't need to run coverage for every test)

When I tried commondream's answer, unfortuately NCover would crash on a regular basis. I don't think it likes that the test system starts .NET 1, 1.1, 2.0, 3.0, 3.5, and 4.0 assemblies , as well as things like silverlight packages and the compact framework (Our product needs to be able to work correctly on all these kinds of assemblies). If you don't need to be insane with running that sort of thing, then the //pn option he describes would probably work fine.

When I tried joe.feser's answer, unfortunately I was unable to figure out the format of NCover's reporting settings file. There's ample documentation on the XML the reporting tool accepts; with the exception of the root XML node it looks for. It refused recognize any of the XML files I generated because the root node was named incorrectly; I assume it was validating against some form of DTD of which I was not aware. If someone would like to post an example file, please go ahead.

Hope this helps anyone with similar issues in the future :)

Billy ONeal
@Stephen I think we called that one function to expand out a wildcard. Not having the code, commondream would need to verify that. I think it was added somewhere around 3.1.4.Glad to hear it is working with the wildcard.
joe.feser