Blog

    Black-Box Testing Techniques for Clinical Calculators: Boundary Values, Equivalence Classes and Unit Errors

    By GauravSeptember 18, 20269 mins read
    On this page

    Black-box testing techniques check software against what it is supposed to do, without looking at the code. For a clinical calculator, such as a dose, score or risk tool inside an EHR or a patient app, that is exactly the right lens: a clinician cares whether the number is right for every valid input and whether the tool refuses inputs it should not accept.

    Startup founders and product or engineering leaders shipping calculators in clinical software will find how to apply equivalence classes, boundary values, unit checks and decision tables, and where trustworthy expected results come from.

    What are black-box testing techniques for clinical calculators?

    Black-box testing techniques for clinical calculators design test cases from the calculator's specification: its inputs, allowed ranges, units, formula, rounding and error behavior. Equivalence class partitioning, boundary value analysis, decision tables and error guessing pick a small set of inputs that together challenge every rule the calculator must follow.

    Shipping a calculator inside clinical software?

    We write the test design from your specification and automate it so every release is checked.

    The FDA guidance General Principles of Software Validation says definition-based or specification-based testing is also known as functional or black-box testing, and that it identifies test cases from what the software product is intended to do.

    Code review and unit tests still matter, but they check the code against the developer's understanding. Black-box tests check the product against the clinical owner's intent.

    Why do calculators need specification-based tests?

    Calculators need specification-based tests because the risky errors are rarely in the formula itself. They sit in the choices around it: which units are accepted, how values are rounded, what happens at the edges of the allowed range and what the tool shows when an input is missing.

    A published formula leaves those choices open. Two correct implementations of the same score can disagree because one rounds an intermediate value and the other does not, and only a test with an expected value written in advance shows which one matches the specification.

    What should the calculator specification say?

    The calculator specification should state every rule a tester needs to decide whether a result is right, in words a clinician has signed off.

    • Inputs: each value, its unit or units, its allowed range and whether it is required.
    • Source: where each input comes from, typed by the user or pulled from the record, and how old it may be.
    • Formula: the published reference, with any adjustments the clinical owner approved.
    • Rounding: which values are rounded, at which step and to how many places.
    • Output: the unit, precision and any category or band the result falls into.
    • Refusals: what the tool shows for out-of-range, missing or conflicting inputs.

    If the specification cannot answer a tester's question, the gap is in the specification, and the clinical owner should close it before the tester guesses.

    How does equivalence class partitioning apply?

    Equivalence class partitioning splits each input into groups the calculator should treat the same way, then tests one or a few values from each group instead of every possible value.

    The same FDA guidance says testing only with expected, valid inputs does not thoroughly test software, and names equivalence class partitioning, boundary value analysis and special case identification, or error guessing, as ways to find test cases with unexpected and invalid inputs. It adds that these techniques do not guarantee every appropriate challenge has been found.

    • Valid range: values inside the allowed range, which should produce a result.
    • Below range and above range: values the specification says to refuse, each with its own message.
    • Missing: the field left empty or not present in the record.
    • Wrong type: text, symbols or a pasted value with stray characters.
    • Wrong unit: a valid number in a unit the calculator does not accept, or in a unit it must convert.

    Partition the outputs too. If the result falls into bands, such as low, moderate and high, every band needs at least one test that lands inside it.

    How does boundary value analysis apply?

    Boundary value analysis tests the values at and next to each edge of a partition, because errors cluster where a less-than should have been a less-than-or-equal.

    Boundary tests for one numeric input with an allowed range
    Test valuePartitionExpected behavior
    One step below the lowest allowed valueBelow rangeRefused with the range message
    The lowest allowed valueValidResult calculated
    One step above the lowest allowed valueValidResult calculated
    One step below the highest allowed valueValidResult calculated
    The highest allowed valueValidResult calculated
    One step above the highest allowed valueAbove rangeRefused with the range message

    The step is the smallest change the input allows, which depends on its precision. Apply the same idea to output bands: choose inputs whose result lands exactly on each band edge and just either side of it.

    Why do unit errors need their own tests?

    Unit errors need their own tests because a correct formula with the wrong unit produces a confident, wrong number, and clinical data arrives in more than one unit.

    The Unified Code for Units of Measure (UCUM) is a code system meant to cover the units of measure in current use in science, engineering and business, with the stated purpose of unambiguous electronic communication of quantities together with their units. In its case-sensitive form, the prefix m means milli and M means mega.

    • Mass: milligrams and micrograms in dose inputs and outputs.
    • Weight: kilograms and pounds typed by users in different countries or settings.
    • Lab values: the same test reported in different units by different laboratories.
    • Case: unit codes compared case-insensitively, so milli and mega are confused.
    • Missing unit: a value from an interface with no unit attached, which should be refused, not assumed.

    For every input that accepts more than one unit, test the same quantity entered in each unit and confirm the results agree to the specified precision.

    How do inputs pulled from the record change the tests?

    Inputs pulled from the record change the tests because the calculator no longer controls how the value was entered. A weight or lab result may arrive from an interface, a device or an older encounter, each with its own unit, timestamp and status.

    • Test a prefilled value with each unit the source systems send.
    • Test a value older than the specification allows, and confirm the user is asked for a new one.
    • Test a corrected or cancelled result, which should not be used.
    • Test a user overriding a prefilled value, and confirm the result and audit record use the override.

    How should rounding be tested?

    Rounding should be tested with inputs chosen so that rounding at the wrong step, or in the wrong direction, changes the displayed result or its band.

    Write cases where an intermediate value sits just below and just above a rounding point. If the specification says to round only for display, the stored result should keep full precision, and a test should check both.

    When do you need a decision table?

    You need a decision table when the calculator's behavior depends on combinations of conditions, such as age group, sex, pregnancy status or kidney function, rather than one input at a time.

    List each condition as a column and each valid combination as a row with its expected rule or result. The table shows untested combinations at a glance and catches rules the specification forgot, such as what happens when two conditions point to different adjustments.

    Where should expected results come from?

    Expected results should come from a source independent of the code under test, agreed before the test runs.

    • Worked examples published with the reference formula, where they exist.
    • Independent calculations by the clinical owner or a second engineer, kept with the test data.
    • A reviewed reference spreadsheet, version-controlled, with its own checks.

    Never take an expected value from the calculator's own output. A test that copies the current answer only proves the code still does what it did yesterday.

    What special cases should error guessing add?

    Error guessing adds the cases experienced testers know break calculators, beyond what the partitions suggest.

    • Zero, negative numbers and very large values in fields that should never hold them.
    • Decimal commas, leading spaces and thousands separators in typed input.
    • Ages calculated from a birth date on the birthday itself and across leap years.
    • Inputs pulled from the record that are older than the specification allows.
    • A user changing one input after the result is shown, with the result left stale.

    How do teams build the test suite step by step?

    • Step 1, review the specification with the clinical owner until every rule is testable.
    • Step 2, partition each input and output, and list the boundaries.
    • Step 3, build decision tables for combined conditions.
    • Step 4, write expected results from independent sources.
    • Step 5, add unit, rounding and error-guessing cases.
    • Step 6, automate the cases as data-driven tests that run on every build.
    • Step 7, trace each case to the rule it covers, so a specification change shows which tests to update.

    What are the common mistakes with black-box testing techniques?

    The common mistakes with black-box testing techniques for calculators make a suite look thorough while it misses the edges.

    • Only typical values: a handful of normal patients, no boundaries and no refusals.
    • Expected values copied from the output: the suite can never fail on a wrong formula.
    • One unit tested: conversions and unit labels never checked.
    • Bands ignored: results tested as numbers, but not the category the clinician acts on.
    • No trace to the specification: when a rule changes, nobody knows which cases are now wrong.

    What does calculator testing mean for your build plan?

    Calculator testing needs clinical time as well as engineering time. Plan specification reviews with the clinical owner early, since most test questions are really specification questions.

    • Agree who signs off the specification and the expected results.
    • Store test data and expected values in version control beside the code.
    • Run the full suite on every change to the calculator, its inputs or its data sources.
    • Ask regulatory counsel early whether the calculator falls under medical device rules, because that changes the documentation required.

    How does Agnotic test clinical calculators?

    Agnotic Technologies reviews your calculator specifications with your clinical owner, designs the partitions, boundaries and decision tables, builds independent expected results and automates the suite in your pipeline. Each case is traced to the rule it checks.

    Test the rules, not just the formula

    Boundaries, units and rounding are where calculators go wrong.

    Sources

    Frequently Asked Questions

    Any team that ships dose, score, risk or conversion calculators in EHRs, patient apps or clinical decision support tools, whether the calculator is new or being moved to a new platform.

    Talk to an engineer about your project

    Send us the specification for your calculator, or the calculator itself. We will propose a test design covering boundaries, units and combinations.

    Go deeper

    Services and solutions on this topic