3 ms·
I think the phase change hypothesis* is a bit wrong. I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avi
by smarx007 10mo ago
I think the phase change hypothesis* is a bit wrong.
I think it happens not at 100% coverage but at, say, 100% MC/DC test coverage. This is what SQLite and avionics software aim for.
*has not been confirmed by a peer-reviewed research.
- cloudhead 10mo agoWhat's MC/DC?
- Antibabelic 10mo agohttps://en.wikipedia.org/wiki/Modified_condition/decision_coverage https://en.wikipedia.org/wiki/Modified_condition/decision_co...
- emoII 10mo agoBasically branch coverage but also all variations of the predicates, e.g. testing both true || true, and true || false
- zweifuss 10mo agoModified Condition/Decision Coverage It's mandated by DO-178C for the highest-level (Level A) avionics software. Example: if (A && B || C) { ... } else { ... } needs individual tests for A, B, and C. Test #,A,B,A && B,Outcome taken,Shows independence for 1,True,True,True,if branch,(baseline true) 2,False,True,False,else branch,A (A flips outcome while B fixed at True) 3,True,False,False,else branch,B (B flips outcome while A fixed at True)
- zweifuss 9mo agoI made a mistake: Test # A B C Result 1 True True False True 2 False True False False 3 True False False False 4 False True True True
- deleted 9mo ago[deleted]
- smarx007 10mo agoModified Condition/Decision Coverage (MC/DC) is a test coverage approach that considers a chunk of code covered if: - Every branch was "visited". Plain coverage already ensures that. I would actually advocate for 100% branch coverage before 100% line coverage. - Every part (condition) of a branch clause has taken all possible values. If you have if(enabled && limit > 0), MC/DC requires you to test with enabled, !enabled, limit >0, limit <=0. - Every change to the condition was shown to somehow change the outcome. (false && limit > 0) would not pass this, a change to the limit would not affect the outcome - the decision is always false. But @zweifuss has a better example. - And, of course, every possible decision (the outcome of the entire 'enabled && limit > 0') needs to be tested. This is what ensures that every branch is taken for if statements, but also for switch statements that they are exhaustive etc. MC/DC is usually required for all safety-critical code as per NASA, ESA, automotive (ISO 26262) and industrial (IEC 61508).
- amarant 10mo agoLimit <=0 appears to include every number between 0 and INT_MIN. I hope you don't have any string inputs, or your test is gonna take a while to run!
- smarx007 10mo agoTo test 'limit > 0' according to MC/DC, you need only two values, e.g. -1 and 1. There may be other code inside the branch using limit in some other ways, prompting more test cases and more values of limit but this one only needs two. But yes, exhaustively testing your code is a bit exhausting ;)