Describe a field's type and limits and get the specific values worth testing — boundary, equivalence, negative and security — each with its reason.
14 cases, 9 worth writing first
2 presence · 2 type · 6 boundary value · 1 equivalence partition · 1 negative · 2 edge case
The limits are what the boundary cases are derived from. A field with no minimum or maximum gets presence, type and security cases but no boundary analysis — which is where most of the value is, so it is worth stating the limits even approximately.
Whether the field is there at all. Absent, empty and null are three different things and are handled differently by most validators.
nullExpect: Rejected as missing.
Why: A JSON body can send an explicit null, which is different from omitting the key. Whether the two mean the same thing is a decision that has to be made rather than discovered.
undefinedExpect: Rejected as missing, naming the field.
Why: Absent, null and empty are three different states. Most validators handle one or two of them and are surprised by the third.
The values at the edges of the allowed range. Off-by-one errors live exactly here, which is why one value either side of each limit finds more defects than a hundred values in the middle.
0Expect: Rejected, with a message naming the minimum.
Why: The minimum is 1, so 0 is the largest invalid value. A comparison written with > instead of >= accepts it, and this is the only test that catches that.
1Expect: Accepted.
Why: The smallest valid value. A comparison written with > instead of >= rejects it, which is the same off-by-one from the other side.
2Expect: Accepted.
Why: Confirms the boundary itself was the edge rather than the whole lower range being wrong.
99Expect: Accepted.
Why: The last comfortably valid value, as a control for the two cases either side of the limit.
100Expect: Accepted.
Why: The largest valid value. A comparison written with < instead of <= rejects it, and an inclusive limit documented as exclusive is one of the commonest specification mismatches there is.
101Expect: Rejected, with a message naming the maximum.
Why: The smallest invalid value above the range.
One value from each class the code treats the same way. The point is economy: if every value from 2 to 98 takes the same path, testing all of them finds nothing that testing one does not.
50Expect: Accepted.
Why: One value standing for everything between 1 and 100. If the code treats them all the same way, testing more of them finds nothing more.
The cases that are valid but unusual, and are therefore the ones nobody wrote code for.
0Expect: Rejected.
Why: Zero is falsy. A validator written as `if (!value)` treats a legitimate zero as a missing value, which is the single most common validation bug in loosely typed languages.
9007199254740993Expect: Rejected or handled without losing precision.
Why: This is one above the largest integer a double can represent exactly, so it silently becomes 9007199254740992. Any system passing identifiers through JSON hits this, and the failure is a wrong record rather than an error.
A value of the wrong type. What a loosely typed language does with "5" where it wanted 5 is rarely what anyone intended.
1.5Expect: Rejected, rather than silently truncated.
Why: Truncating silently turns a quantity of 1.5 into 1 with no error, and the person is charged for one of something they asked for more of.
"5"Expect: Either coerced deliberately or rejected — not accepted by accident.
Why: A form sends every value as a string. Whether "5" becomes 5 should be a decision in the code rather than something that happens to work, because the same looseness makes "5abc" into 5 in some languages and NaN in others.
Values the field should reject, to confirm that it does and that the rejection is usable.
"abc"Expect: Rejected, with a message that does not expose internals.
Why: Confirms the rejection happens before any arithmetic, rather than producing NaN downstream.
# Test cases
14 cases across 1 input, 9 of them high priority.
| Technique | Case | Input | Expect |
| --- | --- | --- | --- |
| Presence | quantity is null | `null` | Rejected as missing. |
| Presence | quantity is absent | `undefined` | Rejected as missing, naming the field. |
| Boundary value | quantity one below the minimum | `0` | Rejected, with a message naming the minimum. |
| Boundary value | quantity exactly at the minimum | `1` | Accepted. |
| Boundary value | quantity one above the minimum | `2` | Accepted. |
| Boundary value | quantity one below the maximum | `99` | Accepted. |
| Boundary value | quantity exactly at the maximum | `100` | Accepted. |
| Boundary value | quantity one above the maximum | `101` | Rejected, with a message naming the maximum. |
| Equivalence partition | quantity in the middle of the range | `50` | Accepted. |
| Edge case | quantity is zero | `0` | Rejected. |
| Type | quantity as a decimal where a whole number is required | `1.5` | Rejected, rather than silently truncated. |
| Type | quantity as a numeric string | `"5"` | Either coerced deliberately or rejected — not accepted by accident. |
| Negative | quantity as a value that is not a number at all | `"abc"` | Rejected, with a message that does not expose internals. |
| Edge case | quantity far beyond any sensible magnitude | `9007199254740993` | Rejected or handled without losing precision. |
## Why each case is here
- **quantity is null** — A JSON body can send an explicit null, which is different from omitting the key. Whether the two mean the same thing is a decision that has to be made rather than discovered.
- **quantity is absent** — Absent, null and empty are three different states. Most validators handle one or two of them and are surprised by the third.
- **quantity one below the minimum** — The minimum is 1, so 0 is the largest invalid value. A comparison written with > instead of >= accepts it, and this is the only test that catches that.
- **quantity exactly at the minimum** — The smallest valid value. A comparison written with > instead of >= rejects it, which is the same off-by-one from the other side.
- **quantity one above the minimum** — Confirms the boundary itself was the edge rather than the whole lower range being wrong.
- **quantity one below the maximum** — The last comfortably valid value, as a control for the two cases either side of the limit.
- **quantity exactly at the maximum** — The largest valid value. A comparison written with < instead of <= rejects it, and an inclusive limit documented as exclusive is one of the commonest specification mismatches there is.
- **quantity one above the maximum** — The smallest invalid value above the range.
- **quantity in the middle of the range** — One value standing for everything between 1 and 100. If the code treats them all the same way, testing more of them finds nothing more.
- **quantity is zero** — Zero is falsy. A validator written as `if (!value)` treats a legitimate zero as a missing value, which is the single most common validation bug in loosely typed languages.
- **quantity as a decimal where a whole number is required** — Truncating silently turns a quantity of 1.5 into 1 with no error, and the person is charged for one of something they asked for more of.
- **quantity as a numeric string** — A form sends every value as a string. Whether "5" becomes 5 should be a decision in the code rather than something that happens to work, because the same looseness makes "5abc" into 5 in some languages and NaN in others.
- **quantity as a value that is not a number at all** — Confirms the rejection happens before any arithmetic, rather than producing NaN downstream.
- **quantity far beyond any sensible magnitude** — This is one above the largest integer a double can represent exactly, so it silently becomes 9007199254740992. Any system passing identifiers through JSON hits this, and the failure is a wrong record rather than an error.
> These are cases to write tests from. Nothing has been executed, and a generated case is a starting point to edit rather than a finished test.Nothing here has been executed, and no case is phrased as a result. These are cases to write tests from — and they cover one field at a time, so the cases that come from two fields interacting are not here and are usually where the interesting defects are.
Test Case Generator runs entirely on your device — the cases are derived in your browser and nothing you enter is sent.
You’re on the Free plan. Compare plans
A generator that emits "test the happy path, test an error, test an edge case" has produced nothing: those are category names, and you already knew them. The value is entirely in the specific values — that a field accepting 1 to 100 should be tried at 0, 1, 2, 99, 100 and 101, and that the two that find bugs are 0 and 101 because off-by-one errors live exactly at the boundary.
All of that is derivable from the constraint, which is why the constraint is the input here rather than a prose description. Give it a type and its limits and you get the values, by the techniques that have names: boundary value analysis, equivalence partitioning, and the negative and security cases each type admits.
Every case carries its reason, because without one a case cannot be judged — it gets kept forever or deleted at random. "Quantity is zero" is a value; "zero is falsy, so a check written as if (!value) rejects a legitimate zero" is something you can act on, and it is also the sentence that stops someone deleting the test next year.
Because the limits are what the useful cases come from. A field accepting 1 to 100 has six boundary values worth trying, and nothing about the sentence "quantity of items" implies any of them. A field with no stated minimum or maximum still gets presence, type and security cases, but it loses boundary analysis — which is where most of the value is.
Because zero is falsy. A validation written as if (!value) return error rejects a legitimate zero, and this is one of the most common defects in input handling in any loosely typed language. The same applies to the empty string and to false.
Because the test is about the output, not the input. A value containing HTML should be stored as written and escaped wherever it is displayed — stripping tags on input is the wrong fix and loses legitimate data, such as a surname containing an angle bracket. The SQL case expects no effect at all, because the query is parameterised.
No, and nothing here is phrased as a result. These are cases to write tests from. An expectation is what should happen, not what did.
No. It derives cases one field at a time, and the cases that come from combinations — a discount that is only valid above a minimum spend, two dates that must be in order — are not here. Those are usually where the interesting defects live, so the scenario planner covers the common flows separately.
Because date handling fails in specific ways: a leap day, a daylight-saving transition where a local time does not exist, the last day of a month under month arithmetic, and the ISO week-numbering boundary where 29 December can fall in week 1 of the following year. Each of those has broken real software.
If a tool here saved you some time, you can put something towards the hosting.Buy me a coffee, on Ko-fi, opens in a new tab