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

line coverage percentage affected by certain forms #104

Open
jasonracey opened this issue Aug 1, 2016 · 3 comments
Open

line coverage percentage affected by certain forms #104

jasonracey opened this issue Aug 1, 2016 · 3 comments

Comments

@jasonracey
Copy link

It appears that certain forms are automatically counted as being covered. This might be because these cases do not contain any logic, but the fact that they are used to calculate lines covered % can generate a misleading result. Here's an example of how to get cloverage to report 100% line coverage when there are no tests:

(ns cloverage-check.math)
(defn add-one [arg] (+ 1 arg))
Forms covered: 33.33 %
Lines covered: 100.00 %

case-a

I've put together a couple of use cases here:
https://github.com/jasonracey/cloverage-check

@lvh
Copy link
Collaborator

lvh commented Aug 8, 2016

What would the correct behavior here be? This doesn't feel wrong -- it just feels that line coverage is not a great measuring stick of coverage :)

@JacekLach
Copy link
Collaborator

To me the real issue here is that cloverage doesn't distinguish between code hit by the file being evaluated, and code hit by the tests.

If we assumed that all test code either lives in separate namespaces (which is common), you could work around using some kind of global flag that ignores instrumentation hits during initial eval, and then is disabled before tests are ran. This seems fragile though, as the failure mode if the convention is not upheld is unintuitive.

Another possible approach is to hook into clojures namespace loading mechanism, insturmenting them as they get requested by test namespaces, rather than preloading them. This is in theory more correct, but could be tricky to get right - it threatens to become recursive, which means the bits of state that cloverage uses to track what it's currently instrumenting get more complicated.

@lvh
Copy link
Collaborator

lvh commented Aug 9, 2016

It might be useful to be able to differentiate between code running in different contexts, agreed. I'm not super sure that it's wrong for Cloverage to report this as-is though: form coverage correctly reports the miss, and line coverage correctly reports that line was looked at at least once. In particular, e.g. if you have a defn with a missing parameter declaration or something, it'd still fail, right?

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