Repository navigation
The Mutant Survived and Every Check Passed Software Engineering Full Course Lecture 8
Full tutorial link > https://www.youtube.com/watch?v=F6rv0ZSmmbs
Lecture 8 of the Software Engineering course. The booking rule of Campus Rooms, a fictional room-booking service, allows 30 through 120 minutes. Its one check passes and every line runs, yet Ari's 120-minute booking is refused. Interactive scenes show which checks challenge your assumptions and which merely repeat them.
Links:
SECourses Patreon: [ https://www.patreon.com/SECourses ]
SECourses Discord: [ https://discord.com/servers/software-engineering-courses-secourses-772774097734074388 ]
You will derive ordinary, boundary and invalid cases from a rule, choose a test scope and say what it leaves open, tell executing code from asserting a result, write an independent oracle, state properties and shrink a failure, read coverage and mutation results, control a clock and judge evidence.
Topics: software testing, boundary value analysis, equivalence partitioning, unit, component and contract tests, test doubles, exploratory testing, test oracles, property-based testing, fuzzing, code coverage, mutation testing, flaky tests, test-first development.
Jump to any scene, the questions, the principles or the sources.
Chapters:
00:00:00 A green check: why was Ari's booking refused?
00:00:41 Run the check: every line executed, nothing looks wrong
00:01:03 Predict: will the 120-minute booking go through?
00:01:14 Ari presses Book: rejected, and the screen offered it
00:01:54 From requirements to the checks themselves
00:02:31 The four rules under test today
00:02:59 How to read an assertion and half-open intervals
00:03:34 Scene 1: sixty minutes passes, is the rule right?
00:04:07 Predict: does one passing example settle it?
00:04:32 A second comparison also accepts 60
00:04:53 Walk the lower edge, then 119
00:05:12 Predict: what does the code answer at 120?
00:05:35 The reveal: one character refuses 120
00:06:23 Inclusive fix: which two cases prove the limit survived?
00:07:22 No upper limit: why 120 alone is not enough
00:08:19 Scene 2: do you have to test every minute?
00:08:54 Three groups, one expected answer each
00:09:06 One value per group still misses the defect
00:09:30 The two edges where the answer changes
00:09:49 Shape and order are separate concerns
00:10:34 A labeled 90-minute trial: which cases keep their job?
00:11:49 Scene 3: can two people still get one room?
00:12:35 Unit check: exact arithmetic, nothing about storage
00:13:00 Component check, one request at a time
00:13:13 Concurrent check: two confirmations, and the unit check stays green
00:13:46 Journey check: the whole path, slowly
00:14:21 Test double: what you gain and what stays unknown
00:15:21 Contract mismatch: the provider raises into booking
00:16:27 Exploring the journey: how do you recover from a lost response?
00:16:58 Reopen the booking: stored Confirmed, screen says Submitting
00:17:31 Keep the discovery as a regression check
00:17:42 Scripted checks, exploration and usability studies
00:18:20 Scene 4: who checked the expected answer?
00:19:05 Follow the 119 through two cards
00:19:26 Derive the expected answer from R-02, and by hand
00:19:57 The test oracle
00:20:17 The helper changes: one check always passes
00:21:16 One assistant drafted the code and the tests
00:22:15 Scene 5: what must stay true after any accepted booking?
00:22:57 Four candidates and two properties
00:24:01 Rejects adjacency: P1 holds, P2 fails
00:24:57 Six generated bookings shrink to the smallest failure
00:25:52 Fuzzing: malformed text and a crash
00:27:01 Scene 6: the line ran, did anything check its answer?
00:27:41 Two of two lines, and nobody looked at the answer
00:28:04 One assertion: same coverage, a failing run
00:28:30 Mutation: the mutant survives without a 120 case
00:29:27 Add one case: mutant detected
00:30:13 An equivalent mutant and the score
00:31:12 Scene 7: same code, same check, different result
00:31:58 The wall clock crosses the start
00:32:48 A fixed clock: five identical runs
00:33:35 Waiting and hoping against an injected failure
00:35:00 Scene 8: what should happen before you fix the bug?
00:35:32 Reproduce, shrink, one hypothesis, confirm
00:36:15 A focused failing check and the smallest change
00:36:57 Check first: test-first development
00:37:47 Refactor under the checks, and what stays open
00:38:47 Review, static analysis and a dynamic check
00:39:30 A contract answers to the requirement
00:39:56 Claim, evidence and what stays open
00:41:01 The eight principles
00:41:39 Six checks with answers
00:42:43 Outside room booking: a file converter that checks itself
00:43:26 Next: what if the input cannot be trusted?
00:43:52 Tools in practice, terms and sources
00:44:44 What you can do now
Music: Stellar Wind by Unicorn Heads, The Engagement by Silent Partner, Night Run Away by An Jone, Chicago by Joe Bagale, Call The Shots by Slynk, Phase Three by Huma-Huma, World Map by Jason Farnham, Bright Future by Silent Partner.
Every name, number and booking is a teaching example from the fictional Campus Rooms service.
Questions and updates: the links above and the comments below. Thank you for watching.
-
00:00:08 Greetings everyone. This is week 8 of the Software Engineering course. Today I am going to show you
-
00:00:14 why a green check can still hide a broken rule, and how to find the checks that challenge you.
-
00:00:20 Here is the rule, R-02, from Campus Rooms, the fictional booking service of this course.
-
00:00:26 A booking lasts 30 through 120 minutes, including both limits. The code shipped with 1 check. It
-
00:00:33 asks duration_ok about 60 minutes and expects true. You will read many checks like this one
-
00:00:40 today. Let's run it. One of 1 checks passed, and the report says every line of the function
-
00:00:45 executed. Nothing here looks wrong, and many teams would stop right here. Now look at what Ari sees.
-
00:00:53 Ari wants room C101 from 10:00 to 12:00, which is 120 minutes, and the screen itself says: choose
-
00:01:00 30 to 120 minutes. So decide before the reveal. The check is green. Will Ari's 120 minute booking
-
00:01:08 go through? Pause the video for a moment and make your prediction. Let's send it. Ari presses Book,
-
00:01:16 and the answer comes back: rejected, 120 minutes. The screen offers that duration, and the code says
-
00:01:23 no. The check told the truth, and only about 60 minutes. Nobody asked it about 120, the one value
-
00:01:31 where this code goes wrong. That leads to the question for today. Which checks would challenge
-
00:01:37 our assumptions, rather than merely repeat them? Every scene of this lecture answers 1 piece of
-
00:01:43 that question. The arrow buttons at the top right of the deck move between pages. The next page
-
00:01:49 shows where this week fits with what you already know. Week 2 linked requirements to checks,
-
00:01:56 and week 7 had reviewers read those checks. This week the checks themselves are under examination,
-
00:02:03 because a link to a weak check gives you very little. By the end you will derive ordinary,
-
00:02:09 boundary and invalid cases from a stated rule, and you will choose a suitable scope for a check and
-
00:02:15 say what it leaves open. You will tell executing code apart from asserting the intended result,
-
00:02:22 explain a property and a small mutation challenge, and recognize shared assumptions,
-
00:02:27 uncontrolled inputs and flaky observations. These are the rules you will test. R-01:
-
00:02:34 no overlapping confirmed bookings in 1 room, and adjacent bookings are allowed. R-02 is
-
00:02:40 the duration rule you just saw. R-03: you can cancel your own future confirmed booking. R-04:
-
00:02:49 a failed notification leaves a confirmed booking confirmed. Each one gets challenged
-
00:02:55 in a different way today. A check is written as an assertion. Read this one in plain words:
-
00:03:02 call the function with 60, and the answer must be true. If it is anything else, the check fails.
-
00:03:09 And the bracket notation you will see on intervals means the start is included and the end is not,
-
00:03:14 the half open intervals from week 1. So 10:00 to 11:00 and 11:00 to 12:00 do not overlap at
-
00:03:20 all. Keep the question of this lecture in front of you: which checks would challenge our assumptions,
-
00:03:27 rather than merely repeat them? Let's start with the friendliest example you can imagine. Scene 1:
-
00:03:35 60 minutes passes. Is the rule right? You will send duration cards through the comparison,
-
00:03:39 one at a time, and hold each answer against R-02. The cards wait on the left. In the middle
-
00:03:46 is the code under test, 30 less than or equal to minutes, less than 120. On the right, each card
-
00:03:53 lands in accepted or rejected, and stays there. The table below records what R-02 requires and
-
00:04:00 what this code answers. Decide first: a 60 minute request passes. Is the rule implemented correctly?
-
00:04:07 Option A, yes, the check is green. Option B, not known yet, because one example leaves the
-
00:04:13 other durations open. Option C, no, 60 should be refused. Pause the video and choose one.
-
00:04:20 Let's run 60. The Step button at the top right moves the demonstration forward by 1 state. 60
-
00:04:26 goes through the comparison and lands in accepted, and R-02 agrees. Now bring in a second comparison,
-
00:04:34 the one that ends in less than or equal to 120. It accepts 60 as well. This one example cannot
-
00:04:40 tell the 2 apart by itself. So the answer is B. A passing example tells you about that example.
-
00:04:47 To learn more, you need cases that could tell right from nearly right, on purpose.
-
00:04:52 Walk the lower edge. 29 is rejected, 30 and 31 are accepted, and every answer still agrees with R-02.
-
00:05:01 119 is accepted too. Still no disagreement anywhere, and the upper limit is 1 minute
-
00:05:07 away. A lot of test suites stop around here. The next card is 120, the last value the rule
-
00:05:15 allows. The code under test uses less than 120. What does it answer here? Option A, accepted,
-
00:05:23 because R-02 includes 120. Option B, it depends on the room. Option C, rejected, because the
-
00:05:30 comparison leaves 120 out. Pause and choose. 120 is rejected, and R-02 says accepted. So the right
-
00:05:39 answer was C. 1 character, less than instead of less than or equal, refuses the longest booking
-
00:05:45 the rule allows. Look at the second comparison in the same row: it accepts 120. For the first time,
-
00:05:52 the 2 comparisons give different answers, and 60 could never have shown you that. 121 is rejected,
-
00:06:01 and that part is right. 1 row disagrees, and only a case at the edge could find it. That gives you
-
00:06:07 the principle of this scene. Test cases should distinguish plausible incorrect behavior from the
-
00:06:14 intended behavior. In short, pick the case that can tell right from nearly right. 60 is friendly.
-
00:06:20 120 is useful. Now change 1 condition. The buttons under Condition switch the demonstration
-
00:06:28 to another case. Inclusive fix changes 1 character and keeps everything else. With less than or equal
-
00:06:35 in place, which 2 cases show the fix kept the upper limit? Option A, 120 and 121. Option B,
-
00:06:42 60 and 119. Option C, 29 and 30. Pause here and pick the pair that could expose a fix
-
00:06:50 gone wrong. Run the same cards. Everything below the edge answers as it did before,
-
00:06:57 so those cards tell you nothing new about this fix. 120 is accepted now, and the disagreement is
-
00:07:04 gone. That is half of the answer, because a fix can repair one end and damage the other. 121 is
-
00:07:11 still rejected. The fix restored the endpoint and kept the limit. So the answer is A: 120 and 121,
-
00:07:20 read together. To see why both cases matter, take the last condition. Someone repairs the bug by
-
00:07:27 deleting the upper comparison altogether. Will the 120 card catch this? Option A, yes, it is the card
-
00:07:35 that failed before. Option B, no, it is accepted either way, so only 121 can catch this. Option C,
-
00:07:43 yes, any failing card will catch it. Take a moment and decide before the cards run. The cards below
-
00:07:50 the edge behave as before, and 120 is accepted. Seen alone, this version looks fixed, and that
-
00:07:57 is exactly the danger. 121 is accepted, and R-02 says rejected. So B was the right answer. These 2
-
00:08:05 cases together separate an inclusive limit from no limit at all. You just found those cases by hand,
-
00:08:12 by walking every card. Next, a way to find them on purpose, without walking every value. Scene 2:
-
00:08:20 do you have to test every minute? Group the inputs that share 1 expected answer, then
-
00:08:25 look hardest where 1 answer becomes another. Here is a number line of durations in minutes, empty
-
00:08:32 for now. Checking every whole minute from 1 to 180 takes 180 checks. What could replace most of them?
-
00:08:40 Option A, values chosen at random until 1 fails. Option B, the durations people pick most often.
-
00:08:46 Option C, 1 value per group of shared answers, plus the edges of each group. Pause and choose.
-
00:08:54 3 groups appear, with 1 expected answer each. Too short is rejected, allowed is accepted, and too
-
00:09:00 long is rejected. Inside a group, the rule treats every value the same way. Take 1 value from each
-
00:09:07 group: 10, 60 and 150. all three agree with R-02. Now look at the last column: the code that leaves
-
00:09:14 out 120 passes all three. So one value per group is a good start, and it still misses the defect
-
00:09:21 from scene 1. The group tells you what to expect. It has no opinion about where the group ends. The
-
00:09:30 decision changes at 2 edges: 29 to 30, and 120 to 121. A plausible mistake lives exactly there.
-
00:09:39 Add 31 and 119, just inside each edge, and you have the 6 edge cases of the first scene. So the
-
00:09:46 answer is C: groups, plus their edges. Not every bad request is a bad duration. The table adds a
-
00:09:52 second question: is this a valid request at all? Time order and shape are separate concerns. With
-
00:09:58 start before end, the duration decides: rejected, accepted, rejected. With end before start,
-
00:10:04 there is no duration to judge, so the reason is the order. A value like 45.5, or the word soon,
-
00:10:11 or nothing at all, is not a whole number of minutes. It is refused for a different reason,
-
00:10:17 so it needs its own case. Each group keeps its own expected answer and its reason. Partitions
-
00:10:24 organize expectations, and boundaries expose where 1 expectation becomes another. In short,
-
00:10:29 group the same answers, then test the edges. Now the rule itself moves. Trial at 90 lowers
-
00:10:36 the upper limit for a labeled, temporary trial. Only that limit changes. Which cases keep their
-
00:10:43 old job, and which ones change? Option A, 29, 30 and 31, at the lower edge. Option B, all 6, as
-
00:10:50 they are. Option C, none, because a new rule needs all new cases. Stop here and choose. The allowed
-
00:10:58 group shrinks to 30 through 90, and the upper edge moves to 90 and 91. Look at the lower edge:
-
00:11:05 it stays exactly where it was. The table compares each case under both rules. The lower 3 keep their
-
00:11:11 answers and their job, so the right answer is A. 91, 119 and 120 change their answer. 89, 90 and
-
00:11:20 91 become the new edge cases. A check written with the old limit would now fail, for a good reason.
-
00:11:28 The trial ends and 120 returns. The baseline cases and their answers come back exactly as they were,
-
00:11:35 and every later scene uses the rule as written. Groups and edges tell you which inputs to try.
-
00:11:42 They say nothing about where in the system to try them. That is the next question. Scene 3: the
-
00:11:50 overlap function passes. Can 2 people still get 1 room? Every check observes part of the system, so
-
00:11:57 match what you want to know with where you should be looking. Here is the system: Ari's browser,
-
00:12:02 the booking handler, Policy with its pure functions, Storage, and the notification provider.
-
00:12:08 This window shows what a check can see, and your 1 green check sees only Policy. The overlap function
-
00:12:15 passes every check. Can 2 concurrent requests still double book room C101? Option A, no,
-
00:12:22 the arithmetic is correct. Option B, no, the function runs on the server. Option C, yes,
-
00:12:28 this check never touches storage. Pause the video and decide what the green check lets you claim.
-
00:12:35 Start with the unit check. It asks the overlap function about 10:00 to 11:00 and 10:30 to 11:30,
-
00:12:41 and the answer is true. It is fast and exact about the arithmetic. Read its row. The claim
-
00:12:47 is that the interval predicate is correct, the scope is 1 pure function, and it says nothing
-
00:12:53 about storage under 2 requests at once. Every row in this table names what it leaves open. Widen
-
00:13:00 the window. A component check runs the handler and Policy with a real store, one request at a time. A
-
00:13:07 conflicting request is rejected, the check passes, and 2 requests never interleave at the same time.
-
00:13:13 Now look only at storage, and run two requests at the same moment. With the check then write from
-
00:13:19 week 6, both are confirmed. 2 confirmations for 1 overlapping time. And the unit check is still
-
00:13:25 green. So the answer is C. Correct arithmetic leaves the rule exposed to 2 operations at once,
-
00:13:32 and only this window can show you. This concurrent check covers the interleavings it tried,
-
00:13:38 and you can read that limit in its row. Week 6's atomic decision is the repair, and this check is
-
00:13:44 what keeps it in place. The widest window is the journey. Ari books by keyboard and reads
-
00:13:50 the status, and the whole route is observed. That is valuable and slow, so it covers only
-
00:13:55 a few cases. The last row is a claim about the notification boundary. Each row pairs a claim with
-
00:14:02 the place it can be observed, and names what stays open. Choose from the claim and the risk of being
-
00:14:09 wrong. That is the principle: the appropriate test scope follows the claim and failure risk, not the
-
00:14:15 prestige of a test label. Choose the check by what you need to know. Test double changes 1 condition:
-
00:14:22 the notification call now goes to a stand-in that the check controls. The real provider drops
-
00:14:28 out of the picture. What do you gain? Option A, fast, repeatable isolation of booking. Option B,
-
00:14:35 evidence that the real provider works. Option C, nothing, because a double only hides
-
00:14:40 problems. Pause and choose. The double fails on request, so you can test R-04 whenever you like:
-
00:14:49 the booking stays confirmed and the notification is marked failed. That is the gain, and the right
-
00:14:55 answer is A. That result holds under the double's assumption: a notification failure stays separate
-
00:15:02 from the booking outcome. The check wrote that assumption down, and nothing here looked any
-
00:15:07 further. The real provider never ran. A double returning the answer you wanted tells you how
-
00:15:13 booking behaves if the provider behaves that way. Its actual failures stay out of view. Now the
-
00:15:21 uncomfortable case. The double based check stays green, while the real provider raises its failure
-
00:15:27 into the booking flow. Which check can see that? Option A, the duration check. Option B, a rerun
-
00:15:34 of the double based check. Option C, a contract check against the real provider. Pause and make
-
00:15:40 your choice. Booking states what it expects, in a form the provider can be checked against:
-
00:15:47 a notification failure remains separate from the booking outcome. That expectation is the
-
00:15:53 contract between the 2. The contract check fails. The actual provider raises into the booking flow,
-
00:16:00 and the double never did, so only this check could show it. The answer is C. Repair the boundary,
-
00:16:06 and keep 1 journey check too: the booking stays confirmed and the failed notification stays
-
00:16:12 visible. Neither side can observe that alone. All of these checks start from something you
-
00:16:19 already suspect. What about the problem nobody has imagined yet? For that, you explore with
-
00:16:25 no script at all. Exploration starts from 1 question rather than a script. Here it is:
-
00:16:31 how does someone recover from a lost response? Let each observation choose your next move. This
-
00:16:37 is the same keyboard journey as the last scene. Ari has filled in room C101, and the form is
-
00:16:44 ready. The screen says draft, and nothing has been read back yet. Submit by keyboard. The screen says
-
00:16:50 submitting, and then the response never arrives. So the next question chooses itself: what can
-
00:16:56 Ari do now? The obvious thing is to reopen the booking. The stored booking comes back confirmed,
-
00:17:03 and the screen still says submitting. That is a mismatch nobody scripted a check for. Now
-
00:17:09 your next check is about the screen, not about storage. Is the mismatch in storage, or in what
-
00:17:15 the interface shows? Storage is fine as it is. After the correction, reopening shows confirmed,
-
00:17:22 on the screen and in storage. You found 1 defect by following a question, and you did not know it
-
00:17:28 was there when you began. Then you keep it. Reopen the booking, and assert that the screen shows
-
00:17:35 confirmed. The discovery is now a repeatable regression check that guards this behavior
-
00:17:40 from now on. These 3 activities answer different questions. A scripted check keeps an expectation
-
00:17:47 you already know. Exploration is guided investigation with recorded observations, and it
-
00:17:53 finds the next expectation. A usability study is a separate question for representative people: can
-
00:18:00 someone complete recovery and explain the outcome? Campus Rooms is a simulated example here, so no
-
00:18:06 such study took place. You have now seen many checks agree with their expected values. The next
-
00:18:12 scene asks a simpler and more awkward question: where did those expected values come from?
-
00:18:20 Scene 4: who checked the expected answer? The check agrees with the code, so follow where each
-
00:18:26 expected result comes from. Start at the top. A helper called longest_allowed returns 119,
-
00:18:33 and the duration function compares against it. Now read the check below. The check computes its
-
00:18:40 expected value with the helper: is 120 within the longest_allowed? Then it asserts that duration_ok
-
00:18:46 gives that same answer. And it passes. How much does this agreement tell you? Option A, quite a
-
00:18:53 lot, because 2 calculations matched. Option B, everything, because the check passed. Option C,
-
00:18:59 little, because both answers share 1 helper. Pause and choose. Follow the 119. Someone
-
00:19:07 read up to 120 as under 120, and that one number flows into the code and into the expected value.
-
00:19:16 The check passes. The code refuses 120, and the expected value says it should. They agree
-
00:19:22 because they share a source, so the answer is C. Now derive the expected answer from R-02
-
00:19:29 itself. Both ends are included, so 120 must be accepted, and 121 must be rejected. Notice that
-
00:19:36 this needed no code at all. Check it by hand as well. 10:00 to 11:00 is 60 minutes, then 60 more,
-
00:19:44 so 120 minutes, and R-02 accepts that. The independent check fails and exposes
-
00:19:50 the defect. Same code, same green check a moment ago, and the only change is where the expected
-
00:19:55 answer came from. The basis for an expected result is called a test oracle. A test oracle,
-
00:20:01 the basis for the expected result, must not simply repeat the defect under examination. In short,
-
00:20:08 get the expected answer from the requirement, not from the code. For any check you read,
-
00:20:13 ask where its expected value came from. Now change the helper and leave the requirement alone. A
-
00:20:21 later cleanup makes it return 90, while R-02 still says 120. What do the 2 checks do? Option A, the
-
00:20:29 self confirming check passes and the independent check fails. Option B, both checks fail. Option C,
-
00:20:35 both checks pass. Pause and think it through. Helper at 90: the self confirming check passes,
-
00:20:42 and the independent check fails, so the right answer was A. The code just lost 30 minutes of
-
00:20:48 allowed bookings, and 1 check stayed green. Helper at 150: the same result. The self confirming check
-
00:20:56 passes again, whatever the number is. A check that passes for every value tells you little
-
00:21:02 about any of them. Helper at 120: now both pass. Only the independent check could tell this value
-
00:21:09 from the others, because it is the only 1 that knows the requirement as written. This same loop
-
00:21:16 appears with code assistants. In this condition, 1 assistant drafted the helper and the tests from
-
00:21:22 1 reading of R-02, and all 5 generated tests pass. What have they shown? Option A, R-02 is satisfied,
-
00:21:30 5 out of 5. Option B, the code matches 1 reading of R-02. Option C, the assistant checked itself,
-
00:21:37 so review can stop. Make your choice before the reveal. Read the row for 120: the test expects
-
00:21:45 false. It carries the same misreading as the code, so the 2 agree, and B is the right answer. An
-
00:21:52 independent check, derived from R-02 as written, expects 120 to be accepted. Against this candidate
-
00:21:59 it fails. Week 13 returns to this loop in detail. An independent oracle strengthens a single check.
-
00:22:06 One example at a time is still slow, though. The next scene states a rule that speaks for many
-
00:22:12 examples at once. Scene 5: what must stay true after any accepted booking? Write the rule as a
-
00:22:20 statement about every sequence of bookings, then feed it candidates. 2 properties sit at the top,
-
00:22:26 and they have no result yet. The calendar below shows 2 rooms from 09:00 to 15:00,
-
00:22:30 and the table will record each candidate as it runs. An example checks 1 case, and a property
-
00:22:37 speaks for all of them. What should remain true after any accepted booking? Option A, no
-
00:22:43 2 confirmed bookings overlap in a room. Option B, every request ends up accepted. Option C, exactly
-
00:22:50 1 booking exists per room. Pause the video and choose the statement you would want to be true.
-
00:22:57 10:00 to 11:00 in room C101 is accepted. P1 holds, because 1 booking cannot overlap anything. So the
-
00:23:04 answer is A, and that statement is R-01. 10:30 to 11:30 overlaps it and is rejected, in the
-
00:23:10 lower half of the lane. P1 still holds, because the refusal is what protects the rule. 11:00 to
-
00:23:17 12:00 touches the first booking at 11. Half open intervals allow that, so it is accepted, and P2
-
00:23:23 holds: a valid adjacent booking is accepted as well. 10:30 to 11:30 in room C202 is accepted. It
-
00:23:32 is the same time as the rejected one, in another room, so there is no conflict here. A property
-
00:23:37 based tool generates many sequences like this and tests these same statements. These 4 are fixed,
-
00:23:44 so you can replay them, and the next conditions show what such a tool adds. Properties expose
-
00:23:51 classes of behavior, but the properties themselves must express the intended rule. In short, state
-
00:23:57 what must always hold, and check the statement too. Now change the predicate. Rejects adjacency
-
00:24:04 makes the comparison less than or equal to on both sides. It now refuses 11:00 to 12:00 after 10:00
-
00:24:10 to 11:00. Which property notices? Option A, P1, no overlapping confirmed bookings. Option B, P2,
-
00:24:18 a valid adjacent booking is accepted. Option C, neither, because both still hold. Decide before
-
00:24:24 the next move. 10:00 to 11:00 is accepted, as before. Now replay the next candidate, 11:00 to
-
00:24:31 12:00, the one that only touches the end of the first one. The comparison calls it an overlap
-
00:24:37 and refuses it, while the rule calls it adjacent. P1 still holds, and P2 fails, so B is the right
-
00:24:43 answer. Think about what that means. A service that refuses everything satisfies P1. You need
-
00:24:50 P2 as well, because the properties have to say the whole rule. Real failures rarely look this tidy.
-
00:24:59 Smallest failure shows 6 generated bookings with the same comparison, and P2 has failed somewhere
-
00:25:06 among them. What would help you the most here? Option A, the smallest sequence that still fails.
-
00:25:12 Option B, rerunning it until it passes. Option C, a longer sequence with more bookings. Take
-
00:25:17 a moment and choose. Remove the bookings that touch nothing. 3 bookings remain, and P2 still
-
00:25:25 fails. The answer is A: every removal that keeps the failure throws away 1 more distraction. Remove
-
00:25:32 another one. 2 bookings remain, and P2 still fails, with 1 valid booking refused. You are close
-
00:25:39 to the cause now. Simpler times still fail. This is the smallest counterexample: 10:00 to 11:00,
-
00:25:46 then 11:00 to 12:00. Property based tools call this reduction shrinking, and they do it for you.
-
00:25:52 The same idea works on input nobody expected. The next condition feeds the parser strange generated
-
00:25:58 text. What does a fuzzer need in order to report a failure? Option A, 1 fixed expected output for
-
00:26:04 every input. Option B, a property any input must meet: a clear answer and no crash. Option C,
-
00:26:11 the source code of the handler. Hold the video and pick one. 3 generated inputs run. A number written
-
00:26:18 as text and a plain word both get a clear answer, and 3 spaces crash the parser. That property is
-
00:26:24 all it needed, so the answer is B. Reduce the failing input: 3 spaces, 1 space, then empty
-
00:26:30 text. All of them still crash, and empty text is the smallest. Feeding generated input like this
-
00:26:36 is called fuzzing. After the correction, nothing crashes. Blank text gets a clear answer: rejected,
-
00:26:44 enter a whole number of minutes. Reduced inputs like this one make excellent regression cases. You
-
00:26:51 have now seen checks that speak for many inputs. How do you know your suite is really looking at
-
00:26:57 what it runs? That is the next scene. Scene 6: the line ran. Did anything check its answer? Coverage
-
00:27:04 reports what executed, and a mutation asks whether the suite would notice a change in the behavior.
-
00:27:11 This is the code as shipped, with the less than, and a suite that calls it twice. The 3 boxes at
-
00:27:17 the top will report the run as it happens. Every line shows as executed, and the run is green.
-
00:27:24 What does that tell you? Option A, the lines ran, and whether any answer was right is still open.
-
00:27:30 Option B, R-02 is implemented correctly. Option C, both boundaries are checked. Pause the video
-
00:27:36 and make your choice before the report appears. Lines executed: 2 of 2. Coverage marks each line
-
00:27:44 that ran during the suite, so this report is accurate. It measures that a line was reached,
-
00:27:49 and nothing about its answer. Now read the suite. It even calls duration_ok with 120, the exact
-
00:27:57 case that fails. The answer comes back false, and nothing compares it with anything. So the answer
-
00:28:02 is A. Add 1 assertion. Coverage stays at 2 of 2, and the run now fails. The same lines ran, and the
-
00:28:10 evidence is different, because this time an answer was compared with R-02. Coverage and mutation
-
00:28:17 results are diagnostic signals about evidence, not substitutes for requirements. Keep that sentence
-
00:28:23 for the rest of the scene, because the next tool looks at the checks themselves. Mutation turns
-
00:28:30 the question around. The code is correct now. Change less than or equal to less than on purpose,
-
00:28:36 and ask whether the suite notices. That deliberate change is a mutation. The suite has no 120 case.
-
00:28:43 What happens when the mutated code runs? Option A, the suite fails at once. Option B,
-
00:28:48 some lines stop executing. Option C, every check passes, and nothing notices. On the correct code,
-
00:28:55 all 4 checks pass, as you would expect. 29, 30, 60 and 121 each give the answer R-02 requires.
-
00:29:04 Apply the mutation: less than or equal to 120 becomes less than 120. Execution looks the same,
-
00:29:10 because the same lines run, as the 2 bars show. All 4 checks still pass. The mutant survived,
-
00:29:19 so C is the right answer. This suite has no case where the 2 versions answer differently, and that
-
00:29:25 is a precise finding. Keep the same mutation and add 1 case: 120 must be accepted. What changes?
-
00:29:32 Option A, line coverage goes higher. Option B, the mutant is now detected. Option C, nothing, because
-
00:29:39 the same lines run. Pause the video and make your choice before the new case runs. The suite now has
-
00:29:46 5 checks, and coverage is still 2 of 2. So the new case added nothing to coverage, and it may be the
-
00:29:52 most useful line of them all. On the mutant, 120 returns false and the check fails. Mutant
-
00:29:59 detected, and the answer is B. You have learned something limited and useful: this suite notices
-
00:30:06 this boundary change. R-02 still decides what is right, and a different mutation could still slip
-
00:30:12 through. A tool also tries another mutation: less than or equal to 120 becomes less than 121. No
-
00:30:20 whole minute case can tell these 2 apart at all. What does its survival call for? Option A, more
-
00:30:27 test cases until it dies. Option B, a bug report against the code. Option C, your judgment, because
-
00:30:33 the 2 behave the same. Stop for a moment and choose. Every check gives the same answer on both
-
00:30:40 versions. It survives, and no new whole minute case could change that. This is an equivalent
-
00:30:46 mutant, so C is the right answer. 2 mutants tried and 1 caught: detected divided by valid is 1 over
-
00:30:52 2, 50 percent. The score points at places to look, and one of these 2 needs no new case at
-
00:30:58 all. Mutation tools let you mark such a change, so it stops counting against the score. In short, use
-
00:31:05 both signals to find weak checks. Next, a check that fails for no good reason at all. Scene 7:
-
00:31:13 same code, same check. Why does it pass and then fail? A check also reads inputs you did not list,
-
00:31:19 like the clock, and you can bring them under control. R-03 says you can cancel your own future
-
00:31:25 booking, and future means its start is later than the current time. Booking B-001 starts at 10 in
-
00:31:32 the morning. The check says Ari can cancel. Its first line reads the time from the wall clock. The
-
00:31:38 same check passes in one run and fails in a later one, with no code change. So what is different
-
00:31:44 now? Option A, the rule changed overnight. Option B, the wall clock crossed the booking's start.
-
00:31:51 Option C, nothing, so rerun it until it passes. Pause and pick the likely cause. Run 1, at 09:58:
-
00:32:00 the marker sits in the allowed zone, cancelling is allowed, and the check passes. Run 2, at 09:59:
-
00:32:08 it passes again. If you ran this check only in the morning, you would believe it forever. Run 3,
-
00:32:15 at 10 o'clock: cancelling is denied, because the booking has started. The check fails, with no code
-
00:32:21 changed. The marker has reached the line, and B is the right answer. Run 4, 1 minute past 10:
-
00:32:28 it fails again. R-03 was right in all 4 runs. The clock is an input this check never controlled
-
00:32:35 at all. A red run here is about the time of day, and it teaches people to ignore red runs. Control
-
00:32:42 irrelevant variation, so a failing check tells you something about the behavior under examination.
-
00:32:48 The repair is to pass the clock into the check. Fixed clock sets it to 9 o'clock. What happens
-
00:32:54 across 5 runs? Option A, 5 identical passes, at any time of day. Option B, passes before 10 and
-
00:33:01 failures after. Option C, random results, as before. Pause the video and make your choice.
-
00:33:08 9 o'clock, 5 runs, 5 passes. The time of day when you run the check no longer matters, so A is the
-
00:33:15 right answer. And 10 o'clock, the exact start, is now a case of its own. 5 runs, denied every time,
-
00:33:21 as R-03 says. A boundary you could only hit by luck is now a line in the check itself. A red run
-
00:33:27 now means the behavior changed. In short, fix what should not matter, so a failure means something.
-
00:33:35 The clock is 1 hidden input, and message timing is another. Injected failure shows 2 ways to
-
00:33:42 check how a notification failure is handled, against R-04. The notification check fails now
-
00:33:49 and then. Which version tells you something about the behavior? Option A, wait longer and rerun it
-
00:33:55 until it is green. Option B, inject 1 failure from a controlled provider and check R-04. Option C,
-
00:34:03 remove the check. Pause here and choose the one you would trust on a busy day. The waiting check
-
00:34:10 sleeps 2 seconds and hopes. 1.2 seconds passes, 2.6 fails, 1.7 passes. The result follows the
-
00:34:17 delay of each run and says nothing about R-04. The injected failure is different. A controlled
-
00:34:24 provider fails on request, and all 5 runs fail the same way: the failed notification undid the
-
00:34:31 booking. That message points at a defect, and the right answer is B. Repair the handler. 5 runs,
-
00:34:38 5 passes: the booking stays confirmed, and the notification is failed, visible and ready to
-
00:34:45 retry. That is R-04, checked the same way every time. You now have checks worth trusting. So what
-
00:34:52 do you do when one of them fails, or when Ari's refused booking lands on your desk? That is the
-
00:34:58 last scene. Scene 8: what should happen before you fix the bug? Back to Ari's refused booking. Find
-
00:35:05 the cause in 4 small moves, then let 1 check guide the change. Ari's 120 minute booking is refused,
-
00:35:14 and you have a suspicion about the code. What comes first? Option A, rewrite the validation
-
00:35:20 function. Option B, wrap the request in a retry. Option C, reproduce the failure with the 120
-
00:35:27 minute case. Pause the video and pick your first move. Reproduce. Ari books C101, 10:00 to 12:00,
-
00:35:35 and the answer is rejected, every time. Now you have something you can run, and the right answer
-
00:35:40 is C. Shrink. Room and time make no difference, so take them away. duration_ok with 120, alone,
-
00:35:48 returns false. That is the smallest failure. 1 hypothesis: the upper comparison leaves out
-
00:35:54 its own endpoint. One idea at a time, so the next result can settle it. Several changes at
-
00:36:00 once would tell you nothing. Confirm it with 1 targeted look: 119 returns true, and 120 returns
-
00:36:08 false. The change is exactly at the upper bound, just where the hypothesis points. Now turn the
-
00:36:16 smallest failure into 1 precise check: assert that duration_ok of 120 is true. It fails,
-
00:36:23 for the reason you expect. That is the second box in the diagram. Make the smallest change:
-
00:36:28 1 character, less than becomes less than or equal. Resist the urge to tidy up anything else while
-
00:36:34 the check is still failing. Rerun. All 6 boundary cases pass, and that check stays behind to guard
-
00:36:41 the meaning of the rule. The loop closes, and the next change begins from a safer place. So,
-
00:36:47 tests are feedback instruments whose value depends on the claims, observations and assumptions they
-
00:36:53 preserve. In short, a check is only as good as what it holds on to. Same rule, a different order:
-
00:36:59 check first. You write the check before the code. What does that give you? Option A,
-
00:37:04 the expected behavior is explicit before any code changes. Option B, a correct requirement,
-
00:37:10 automatically. Option C, no further need for review. Pause the video and choose.
-
00:37:16 The check states the expected behavior, and it fails because the behavior does not exist yet.
-
00:37:22 That is the explicit statement you were after, so A is the right answer. Write just enough code
-
00:37:28 to make it pass. This order is called test first development. It makes the target visible before
-
00:37:34 you touch anything. The check is as right as the requirement it came from. If the requirement
-
00:37:40 itself said under 120, a check written first would carry that mistake faithfully. The fix is in.
-
00:37:48 Refactor restructures the code with named limits. What should the checks tell you after this? Option
-
00:37:54 A, new answers, since the code moved on. Option B, the same answers on every case. Option C, nothing,
-
00:38:02 because refactoring needs no checks. Take a moment and choose. The structure changes: the limits now
-
00:38:09 have names. The decision is meant to stay the same, and this is where the checks earn their
-
00:38:14 place. All 6 cases give the same answers, so the right answer is B. The checks held the meaning
-
00:38:21 still while the code moved around them. Say what this leaves open as well. A duration that arrives
-
00:38:28 as text, 2 requests at the same moment, and the keyboard journey were never exercised here. Higher
-
00:38:35 level checks still have their own work to do. So many kinds of evidence, each with its own limit.
-
00:38:41 Let's line them all up on 1 page, and see what each one lets you claim. Reading, analyzing and
-
00:38:49 running answer different questions. Some evidence arrives before the code ever runs, so let's begin
-
00:38:55 there, with the same shipped comparison. Review: a person compares less than with both included
-
00:39:01 in R-02. The operator contradicts the rule, and no code had to run to see that. Static analysis:
-
00:39:08 a tool reads every route without running the service. It reports that the minutes value
-
00:39:14 from the request can be none at this comparison, a case the checks have not tried so far. A dynamic
-
00:39:20 check runs the code. 1 execution with 1 input: duration_ok of 120 returns false. It is concrete,
-
00:39:27 and it tells you about that execution. You can also state a contract. A precondition: minutes
-
00:39:33 is a whole number. A postcondition: true exactly when minutes is from 30 through 120. An invariant:
-
00:39:41 no 2 confirmed bookings overlap in 1 room. Look under each one: it is justified by a requirement,
-
00:39:47 R-02 or R-01. A contract written without that link would only restate what the code happens
-
00:39:54 to do. Now line up the evidence. Each row keeps 3 things together: the claim, the evidence for it,
-
00:40:01 and what stays open. 120 is accepted and 121 is rejected: the boundary table and a
-
00:40:10 detected mutant support that. Parsing the value at the request boundary stays open. Concurrent
-
00:40:16 requests cannot confirm an overlap: a concurrent check at the storage boundary supports that,
-
00:40:23 for the interleavings it exercised. A failed notification leaves the booking confirmed:
-
00:40:29 a double and a contract check support that, until the provider changes. And reopening
-
00:40:36 after a lost response shows confirmed, from the regression example exploration found. Whether
-
00:40:42 people understand that status is a separate study. A passing suite is evidence with an edge,
-
00:40:48 and now you can say where the edge is. Let's collect the 8 principles of this lecture, and then
-
00:40:54 you can test yourself on 6 questions, with the answers 1 click away. Here are the 8 principles,
-
00:41:02 one per scene, and each card links back to its scene. Decide your answer to each question first,
-
00:41:08 before you open the answer. The first 4 say this. Pick cases that can tell right from nearly right.
-
00:41:14 Group the same answers, then test the edges. Choose the check by what you need to know.
-
00:41:20 Get the expected answer from the requirement, never from the implementation you are testing.
-
00:41:25 And the second 4. State what must always hold, and check the statement too. Use coverage and
-
00:41:31 mutation to find weak checks. Fix what should not matter. And remember that a check is only as good
-
00:41:37 as what it holds on to. First question: which 2 cases distinguish an inclusive 120 minute limit
-
00:41:44 from no upper limit? Decide first, and then open the answer. 120 must be accepted and 121 rejected,
-
00:41:54 under otherwise valid conditions. Either case alone leaves a wrong version standing. Second:
-
00:42:00 do adjacent intervals overlap under the course rule? The answer is no. The end of 1 may equal
-
00:42:06 the start of the next, because the intervals are half open. Question 3: why test the storage
-
00:42:13 boundary as well as the overlap function? Correct local arithmetic alone leaves the rule unprotected
-
00:42:19 against concurrent operations. Question 4: why can the code and its test agree while both are wrong?
-
00:42:26 They may share the same mistaken assumption, or calculate the expected result using the defective
-
00:42:31 logic. Question 5: does a test double establish that the real provider honors its contract? The
-
00:42:37 answer is no. It isolates a claim, and you still need evidence at the real boundary. The last check
-
00:42:44 leaves room booking behind. A file converter passes a test whose expected output is produced
-
00:42:51 by the same conversion function. What would make this test stronger? Use an independently derived
-
00:42:58 small example, and a property justified by the format's meaning, including a relevant boundary.
-
00:43:05 If round trip conversion is promised, check it too. A shared defect can make both directions
-
00:43:11 agree while still producing the wrong result. That is the oracle scene in a new setting. 1
-
00:43:18 page is left: what carries forward to next week, the terms of this lecture, and where
-
00:43:23 to read more. Week 9 starts from this question: what must remain true when a request, dependency
-
00:43:31 or assumption cannot be trusted? Correctness now includes whether an action is permitted at all.
-
00:43:37 3 things carry forward: expected results derived from the requirement, explicit invariants written
-
00:43:45 as properties you can check, and controlled clocks and doubles, so that a red check means something.
-
00:43:52 In practice, as of 2026: pytest and JUnit run example checks, Hypothesis generates property
-
00:43:59 based cases, and Stryker and mutmut run mutation analysis. coverage.py measures executed lines,
-
00:44:06 Playwright drives complete browser journeys, and Pact checks a consumer's expectations against a
-
00:44:12 provider. These are examples, and the reasoning works with any of them. In the middle are the
-
00:44:18 terms of this week, from test case and boundary case to test oracle, shrinking, mutation and flaky
-
00:44:25 check. On the right are the sources, starting with the software engineering body of knowledge.
-
00:44:31 The rest are the computing curricula final report, the Hypothesis and Stryker documentation, Software
-
00:44:37 Engineering at Google on testing, the exploratory testing syllabus, and Pact on contract testing.
-
00:44:44 So today a green check lost its authority. You found cases that can tell right from nearly right,
-
00:44:50 and you matched each check to what it can observe and to an expected answer it did not copy.
-
00:44:56 You stated properties, tested your tests with mutations, and brought the clock under control.
-
00:45:02 Thank you for watching, and I will see you in the next lecture, week 9, on security and privacy.
