You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/1-implement-and-rewrite-tests/testing-guide.md
+1-22Lines changed: 1 addition & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,24 +30,14 @@ Testing means:
30
30
31
31
### Step 1: Determining the space of possible inputs
32
32
Ask:
33
-
- What type of value is expected?
34
-
The exact data type the function requires to run cleanly (e.g., Number, String, Boolean, Array, or Object).
35
-
33
+
- What type of value is expected?
36
34
- What values make sense?
37
-
Inputs that are logically valid and physically possible based on the real-world problem you are solving.
38
-
39
35
- If they are numbers:
40
36
- Are they integers or floating-point numbers?
41
-
Integers are for whole counts (e.g., count = 5); floating-point numbers are for precise measurements or money (e.g., price = 19.99).
42
-
43
37
- What is their range?
44
-
The minimum and maximum allowable numeric values constraints (e.g., a percentage must be between 0 and 100).
45
-
46
38
- If they are strings:
47
39
- What are their length and patterns?
48
-
The specific structure strings must follow, such as character limits (e.g., 8-20 characters) or specific formats (e.g., an email pattern like name@domain.com).
49
40
- What values would not make sense?
50
-
Inputs that break reality or logic, such as a negative age (-5), an impossible date, or text strings passed to a multiplication function.
51
41
52
42
### Step 2: Choosing Good Test Values
53
43
@@ -56,10 +46,7 @@ Inputs that break reality or logic, such as a negative age (-5), an impossible d
56
46
These confirm that the function works in normal use.
57
47
58
48
- What does a typical, ordinary input look like?
59
-
A standard, error-free value safely in the middle of your expected range (e.g., using 25 for an adult age check).
60
-
61
49
- Are there multiple ordinary groups of inputs? e.g. for an age checking function, maybe there are "adults" and "children" as expected ordinary groups of inputs.
62
-
Yes; any time your code uses an if/else or switch statement to categorize data, each distinct category forms its own ordinary group.
63
50
64
51
65
52
#### Boundary Cases
@@ -72,22 +59,14 @@ These values are where logic breaks most often.
72
59
Every outcome must be reached by at least one test.
73
60
74
61
- How many different results can this function produce?
75
-
It produces exactly as many results as there are logical paths, code branches, or conditional statements (if, else if, else, catch).
76
-
77
62
- Have I tested a value that leads to each one?
78
-
You have only if your test cases intentionally execute every single code path at least once (known as 100% code coverage).
79
63
80
64
#### Crossing the Edges and Invalid Values
81
65
82
66
This tests how the function behaves when assumptions are violated.
83
67
- What happens when input is outside of the expected range?
84
-
The function should reject it by throwing an error or returning a safe default/fallback value (like null or false) instead of breaking.
85
-
86
68
- What happens when input is not of the expected type?
87
-
It risks triggering unexpected JavaScript behavior (like "5" + 5 = "55"). Good functions guard against this with explicit type checks (typeof).
88
-
89
69
- What happens when input is not in the expected format?
90
-
String parsers, data formatters, or regular expressions will fail to match, which should be caught cleanly without crashing the application.
0 commit comments