-
Notifications
You must be signed in to change notification settings - Fork 784
branch coverage of &&
not perfect
#189
Comments
Another example opts = opts || {};
opts.maxBuffer = opts.maxBuffer || 2000 * 1024; In this piece of code However |
Yes, these are known issues - I believe there is another issue for the |
However opts.maxBuffer is ALWAYS falsey so it uncorrectly marks opts.maxBuffer as covered (it also correctly marks || 2000 * 1024 as covered). Even if its falsy, it is still covered (executed), otherwise you won’t get to the || part. Or am I getting something wrong here? |
The first part is covered in terms of statements coverage, not if you're speaking of branch coverage. Well it's covered only partially, the truth-y branch in this example |
Considering If Further, the However...
So for this:
I would say there are only 2 cases: But for this:
I would say there are 3 cases: |
Just wanted to know if there was any update regarding this. function Foo (options) {
options = options || {};
this.options = {
bar: options.bar || 0,
baz: options.baz || 1
};
} If I just create one instance of Foo in my test without ever adding options it will be considered 100% covered. |
I have a branch that is
a && !b
It makes that branch as 100% coveraged even though
b
is alwaysfalse
.It never says
a && !b
is not covered becauseb
is nevertrue
.I suspect that we should really have 4 cases here, for
(true, true)
,(false, false)
,(true, false)
and(false, true)
.If any of thoses cases are covered it seems unfair to say its 100% branch covered.
The text was updated successfully, but these errors were encountered: