Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Covering Child Processes or Merging Results #97

Closed
AdrianSchneider opened this issue Sep 27, 2013 · 4 comments
Closed

Covering Child Processes or Merging Results #97

AdrianSchneider opened this issue Sep 27, 2013 · 4 comments

Comments

@AdrianSchneider
Copy link

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!

@gotwarlost
Copy link
Owner

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.

@gotwarlost
Copy link
Owner

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

@AdrianSchneider
Copy link
Author

It did, yes. Thanks!

On Mon, Dec 16, 2013 at 9:00 PM, Krishnan Anantheswaran <
notifications@github.com> 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//issues/97#issuecomment-30726420
.

Adrian Schneider

@ORESoftware
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants