Istanbul: Covering Child Processes or Merging Results

Created on 27 Sep 2013  Â·  4Comments  Â·  Source: gotwarlost/istanbul

Is it possible to capture coverage from child processes, or perhaps merge multiple coverage reports together?

I'm testing a small application which acts as a service in a larger SOA system. I have my code coverage working properly for unit tests, and I am very happy with the results. Everything is tested very granularly (all dependencies, including external-reaching ones like request, httpreq/httpres). Code coverage is fairly accurate.

I also have some very basic acceptance tests to ensure the application is wired together properly, and basic functionality works. The test spawns some child processes (a webserver simulating the feed it consumes, and a worker to consume it) and performs some very basic assertions. Unfortunately, I lose almost all coverage possibilities here because the acceptance test doesn't actually do anything but spin up other applications. I find this coverage valuable because it checks the wiring & real implementations of http requests, database queries, etc. that I cannot get (and do not want) from unit tests.

Any suggestions or ideas would be very helpful.

Thanks!

Most helpful comment

This is a sketch of what you might do. Assuming all the entry points to your child processes are node.js files instead of running node foo.js run istanbul cover foo.js --dir ./coverage/dir1 , istanbul cover foo2.js --dir ./coverage/dir2 and so on. If all your child processes exit cleanly, they _should_ write a coverage.json file in each of those output directories.

Then run istanbul report to get a consolidated report of all the coverage files.

Use istanbul help cover and istanbul help report to get an idea of all the options available.

Hope this helps. Let me know how it goes.

All 4 comments

This is a sketch of what you might do. Assuming all the entry points to your child processes are node.js files instead of running node foo.js run istanbul cover foo.js --dir ./coverage/dir1 , istanbul cover foo2.js --dir ./coverage/dir2 and so on. If all your child processes exit cleanly, they _should_ write a coverage.json file in each of those output directories.

Then run istanbul report to get a consolidated report of all the coverage files.

Use istanbul help cover and istanbul help report to get an idea of all the options available.

Hope this helps. Let me know how it goes.

@AdrianSchneider - did this work for you? Can I close this issue?

It did, yes. Thanks!

On Mon, Dec 16, 2013 at 9:00 PM, Krishnan Anantheswaran <
[email protected]> wrote:

@AdrianSchneider https://github.com/AdrianSchneider - did this work for
you? Can I close this issue?

—
Reply to this email directly or view it on GitHubhttps://github.com/gotwarlost/istanbul/issues/97#issuecomment-30726420
.

Adrian Schneider

This Q/A helped a lot. Just a thought, since Istanbul is CPU intensive, best/easiest thing to do might be to generate a bash script like so:

istanbul cover foo1.js --dir ./coverage/dir1
istanbul cover foo2.js --dir ./coverage/dir2
istanbul cover foo3.js --dir ./coverage/dir3
istanbul cover foo4.js --dir ./coverage/dir4

istanbul report

since as far as I understand there's no real reason to run them in parallel, running them with bash is straightforward.

Was this page helpful?
0 / 5 - 0 ratings