Urgent.News

What's breaking now, across thousands of outlets.

Tech

MC/DC coverage for JavaScript

A checkout function can have 100% line and branch coverage without a test for an expired session. Both return paths run. Both tests pass. But removing the expiry check still leaves the suite green. MC/DC coverage asks a more specific question: has each condition been shown to change the decision on its own? Here's what that looks like in JavaScript, using a small example we ran with Supercov. The…

JavaScript code coverage tools can measure Modified Condition/Decision Coverage (MC/DC), which ensures each condition independently affects the decision outcome. In this example, a checkout function's condition is signedIn && !expired. To achieve MC/DC, tests must demonstrate that changing one condition independently alters the decision's result.

The original tests cover valid sessions and signed-out users but miss the case where a signed-in customer has an expired session. To address this gap, a new test is added to check the checkout denial for a signed-in customer with an expired session. After adding this test, MC/DC coverage improves to 50%, indicating the condition now independently affects the decision outcome.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Unreal C++ Course Chapter 114 - 115.

Very straight forward blueprint and C++ use of attack montages, I also included a check to see if the character state was unequipped, which looks like it will be the next lesson.

More from Friday 25 September →