Skip to content

Code Coverage Support added - #74

Closed
arunoda wants to merge 21 commits into
caolan:masterfrom
arunoda:master
Closed

arunoda wants to merge 21 commits into
caolan:masterfrom
arunoda:master

Conversation

@arunoda

@arunoda arunoda commented May 28, 2011

Copy link
Copy Markdown

Expresso's Code Coverage support added to nodeunit

inorder to use it.
you've define requires as follows
var a = require('a');
instead
var a = require('../lib/a')

Then it'll automatically detect this and added code coverage support.
and display the summery.
If you need more information add -cr option
eg:- nodeunit -cr tests

if you need to ommit Code Coverage you can use -ci option
eg:- nodeunit -ci tests

And this will not affect existing tests written in Nodeunit and above little require modification adds the coverage support

arunoda added 5 commits May 29, 2011 00:26
-c and -cv options
this requires expresso like module loading to be work
need to mention require('main') instead require('../lib/main')
once you've added lib folders dependencies as require('depname')
nodeunit will automatically detect it and added the code coverage support
--
-cr option to display coverage results in depth including source code view
eg:- nodeunit -ci tests/
package.json updated with dependencies
@alfredwesterveld

Copy link
Copy Markdown

code coverage would be nice

@arunoda

arunoda commented Jun 7, 2011

Copy link
Copy Markdown
Author

Yes. that's what I forked this. and you checkout myfork and have a npm install

@arunoda arunoda closed this Jun 7, 2011
@arunoda

arunoda commented Jun 7, 2011

Copy link
Copy Markdown
Author

Yes. that's what I forked this. and you checkout myfork and have a npm install

@arunoda arunoda reopened this Jun 7, 2011
@s3u

s3u commented Aug 29, 2011

Copy link
Copy Markdown

Any update on this pull request?

@arunoda

arunoda commented Aug 29, 2011

Copy link
Copy Markdown
Author

Since there is no such update. I'm gonna push forked version of nodeunit to NPM.
How about that?

@caolan

caolan commented Oct 29, 2011

Copy link
Copy Markdown
Owner

Hi arunoda, thanks for your work on this. However, I'm unable to see any coverage output when I run test suites using your updated code. It runs the tests fine, but there's no coverage report.

I have the code under test in 'lib' and the tests in 'test'. The tests reference the code in lib by doing require('../lib/foo'). I run the tests by doing "nodeunit -cr test" in the project directory. Am I missing something?

@BryanDonovan

Copy link
Copy Markdown
Contributor

I think we need a solution that doesn't require a particular directory structure. Perhaps 'test' and 'lib' can be defaults, but a way to pass in the paths via the command line seems like a necessary feature.

@arunoda

arunoda commented Oct 30, 2011

Copy link
Copy Markdown
Author

Yes :) A simple thing
You've to require('foo') instead of require('../lib/foo')
That's how they detect for code coverage. If not they just ignore it.

On Sun, Oct 30, 2011 at 3:45 AM, Caolan McMahon <
[email protected]>wrote:

Hi arunoda, thanks for your work on this. However, I'm unable to see any
coverage output when I run test suites using your updated code. It runs the
tests fine, but there's no coverage report.

I have the code under test in 'lib' and the tests in 'test'. The tests
reference the code in lib by doing require('../lib/foo'). I run the tests
by doing "nodeunit -cr test" in the project directory. Am I missing
something?

Reply to this email directly or view it on GitHub:
#74 (comment)

Arunoda Susiripala

@arunoda http://twitter.com/arunoda
http://gplus.to/arunodahttps://github.com/arunoda
http://www.linkedin.com/in/arunoda

@arunoda

arunoda commented Oct 30, 2011

Copy link
Copy Markdown
Author

I agree with you. lib should be default but there should be some option to
add folders to the list.

On Sun, Oct 30, 2011 at 3:51 AM, Bryan Donovan <
[email protected]>wrote:

I think we need a solution that doesn't require a particular directory
structure. Perhaps 'test' and 'lib' can be defaults, but a way to pass in
the paths via the command line seems like a necessary feature.

Reply to this email directly or view it on GitHub:
#74 (comment)

Arunoda Susiripala

@arunoda http://twitter.com/arunoda
http://gplus.to/arunodahttps://github.com/arunoda
http://www.linkedin.com/in/arunoda

@joeferner

Copy link
Copy Markdown

Great work! I do agree with Raynos though, this is a breaking change. It would be better to have this off by default. It might also be nice to be more explicit on which requires are part of the coverage, maybe nodeunit.require("mydep") this would also reduce the chance of breaking current projects.

@joeferner

Copy link
Copy Markdown

Found a bug. If you specify more than one file on the command line or use globs on the command line the code coverage will be kicked off multiple times (ie nodeunit tests/*).

The problem appears to be that "setUpCodeCoverage" is called once for each file. It should be moved below.

 if(!codeCoverage.enabled) {
     startTesting();
+} else {
+    setUpCodeCoverage();
 }

@felipesilva

Copy link
Copy Markdown

I would love to see this feature becomes true :) Any news about this pull request?

@joeferner

Copy link
Copy Markdown

@felipesilva while you wait you might want to checkout this out (https://github.com/nearinfinity/node-covershot) we wrote this to be a framework agnostic coverage tool.

@felipesilva

Copy link
Copy Markdown

@joeferner wow ;) tks.

@haraldrudell

Copy link
Copy Markdown

mochawrapper

I just wrote a node module that automates coverage reporting. It is based on mocha, jscoverage and node's assert. You do not have to modify require or use make or enviornment variables.

It is hosted on github:
https://github.com/haraldrudell/mochawrapper

@peter-mouland

Copy link
Copy Markdown

was this ever merged in?

@caolan

caolan commented Mar 28, 2014

Copy link
Copy Markdown
Owner

This is an old issue and there are tools out there that can now do code coverage with nodeunit. In the future it would be nice to offer some easy integration but for now it works.

@caolan caolan closed this Mar 28, 2014
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

Successfully merging this pull request may close these issues.

10 participants