Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

OS 8.2 (2 of 2): Regression tests and releases

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

45 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

The Friday fix

On Friday a developer fixes a small bug in the shop app. Only that bug is tested.

On Saturday, the busiest day, customers cannot pay. The fix broke the payment page.

A small change can break an old, working part. How do teams stop this?

Key words

WordWhat it meansExample
Regression testingRunning old tests again to check a change broke nothing else.Run all 200 tests
ReleaseGiving the new version to its users.Version 2.1 reaches the users
Planned releaseA release on a set date, after the planned work and tests.Every first Monday
Reactive releaseAn urgent release to deal with a serious problem.A fix for a security weakness
RollbackGoing back to the last good version.Undo version 2.1
Version numberNumbers that name each release.2.4.1
CriticalSo important that the product cannot go out without it.Payment must work
ControlDeciding who may release, and when.The lead developer says yes

The cells students fill in are left blank in this preview.

Planned releases wait, reactive ones cannot

Planned releaseReactive release
WhyPlanned changes are readySomething is wrong now
WhenOn a set dateAs soon as it is safe
TestsThe full set of testsAt least the critical tests
ExampleVersion 2.1 with dark mode, every first MondayA fix for a weak place that attackers use today
RiskLow: there was time to checkHigher: there is less time

The cells students fill in are left blank in this preview.

Match each word to its story

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Try it: a fix that breaks something

Code: python
def price(age):
    if age < 5:
        return 0
    if age < 16:
        return 1.0
    return 2.5

def run_tests():
    assert price(3) == 0, "free test failed"
    assert price(10) == 1.0, "child test failed"
    assert price(30) == 2.5, "adult test failed"
    print("All tests passed")

run_tests()

# A developer wants children under 6 to travel free. On line 2 they mean to change 5 to 6, but they type 60.
# Make that change, then press Run. (< means "is smaller than")
# Read which old test now fails. The free test still passes.

Make a free account to save your work and track your progress.

Run the old tests after every change

After a change, run the old tests again. This is regression testing. A regression is something that used to work and now does not.

The more tests are automatic, the cheaper this is. Teams often run them after every change.

Do not skip tests when in a hurry

Tip

Many people think an urgent fix is too urgent to test. A rushed release with no tests is when new problems appear. In a reactive release, always run at least the critical tests.

Tests and approval control a release

flowchart TD
  change[A change is ready] --> kind{Planned or reactive?}
  kind -->|planned| full[Run all regression tests]
  kind -->|reactive| critical[Run the critical tests]
  full --> ok{Pass?}
  critical --> ok
  ok -->|yes| approve[Release manager approves]
  ok -->|no| back[Back to the developer]
  approve --> release[Release, and watch the product]
  release --> problem{A new problem?}
  problem -->|yes| rollback[Rollback to the last good version]

Your turn: the release gate

Your team has a list of test results. Each is a name, True or False for critical, and True or False for passed. can_release gives True or False. A planned release needs every test to pass. A reactive release needs every critical test to pass. must_fix_later gives the names of tests that failed but are not critical. Press Run Tests.

Code: python
# results is a list of tests. Each one is a tuple: (name, critical, passed).
#   critical is True if the product cannot go out with this test failing.
#   passed is True if the test passed after the change.
# For one test: test[0] is the name, test[1] is critical, test[2] is passed.
# kind is "planned" or "reactive".

def can_release(results, kind):
    # planned release: every test must pass.
    # reactive release (an urgent fix): every CRITICAL test must pass.
    #   other failed tests are allowed, but they must be fixed later.
    return False


def must_fix_later(results):
    # The names of the tests that failed and are not critical. Keep the order.
    return []

Make a free account to save your work, or press Start lab to work through the whole lesson.

Number the version

Version numbers have three parts: major, minor and patch. A bug fix raises the patch. A new feature raises the minor and sets the patch to 0. A big change raises the major and sets the rest to 0. Fill in next_version. Press Run Tests.

Code: python
# A version number has three parts: major.minor.patch, for example "2.4.1".
#   a big change that may break old things:   major goes up by 1, minor and patch go to 0
#   a new feature:                             minor goes up by 1, patch goes to 0
#   a bug fix:                                 patch goes up by 1
# kind is the text "major", "minor" or "patch".

def next_version(current, kind):
    # Hint: "2.4.1".split(".") gives ["2", "4", "1"]. int("4") is 4.
    return ""

Make a free account to save your work, or press Start lab to work through the whole lesson.

Check: releases and versions

Have a go

Check: releases and versions

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Key words crossword

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Final check

Have a go

Final check

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.