Testing and maintenance
導入済み
19:05
プログラム開発ライフサイクル
リリースまでに到達した微小なバグを修正するには巨額の費用がかかり、早期に発見するよりも遥かに高い cost が発生します。だからこそ私たちは単にコードをタイピングし始めません。私たちは…に従います。
英語のナレーション・英語と中国語の字幕を切り替え可能
このレッスンの内容
| English | 意味 |
|---|---|
| code/kəʊd/ | Instructions written in a programming language for a computer to follow. |
| 16-bit integer | A whole number stored using 16 binary digits. |
| conversion/kənˈvɜːʃn/ | The process of changing a value from one data type to another. |
| overflowed | Describes a value that was outside the range its storage could represent. |
| run-time error/rʌn taɪm ˈerə/ | 実行時エラー |
| routine/ruːˈtiːn/ | A set of instructions that performs a particular task within a program. |
| test data/test ˈdeɪtə/ | Data chosen to check whether a program works as expected. |
| testing/ˈtestɪŋ/ | Running a program with chosen inputs to check that it gives the expected outputs. |
| syntax error/ˈsɪntæks ˈerə/ | 構文エラー |
| keyword/ˈkiːwɜːd/ | A word with a fixed meaning in a programming language or pseudocode. |
| translation/trænˈsleɪʃn/ | Expressing the meaning of a message or text in another language. |
| array index | A whole number that identifies the position of an item in an array. |
| exception/ekˈsepʃn/ | An event that signals an error or unusual condition while a program runs. |
| logic error/ˈlɒdʒɪk ˈerə/ | ロジックエラー |
| loop/luːp/ | A structure that repeats a sequence of instructions. |
| conditions/kənˈdɪʃnz/ | A requirement or circumstance that affects what happens or whether something is true. |
| tracing/ˈtreɪsɪŋ/ | The process of following a program step by step and recording variable values. |
| translator/trænˈsleɪtə/ | A program that changes code into a form a computer can execute. |
| dry run/draɪ rʌn/ | ドライラン |
| variable/ˈveərɪəbl/ | A quantity or named value that can change or take different values. |
| trace table/treɪs ˈteɪbl/ | A table recording variable values and outputs as an algorithm's steps are followed. |
| walkthrough/ˈwɔːkθruː/ | ウォークスルー |
| White-box testing/waɪt bɒks ˈtestɪŋ/ | Testing that uses the internal structure of code to design tests. |
| statement/ˈsteɪtmənt/ | A line of code that tells a program what to do. |
| branch/bræntʃ/ | A path of instructions chosen according to a condition or value. |
| Black-box testing/blæk bɒks ˈtestɪŋ/ | Testing that uses the specification to design tests without examining the code. |
| specification/ˌspesɪfɪˈkeɪʃn/ | A description of what a program must do and the requirements it must meet. |
| Integration testing/ˌɪntɪˈɡreɪʃn ˈtestɪŋ/ | Testing combined modules to check that they work together correctly. |
| modules/ˈmɒdjuːlz/ | Separately organised program components that perform defined tasks and communicate through interfaces. |
| interfaces | Points where modules connect and exchange data or commands. |
| stub/stʌb/ | スタブ |
| alpha testing/ˈælfə ˈtestɪŋ/ | αテスト |
| beta testing/ˈbiːtə ˈtestɪŋ/ | βテスト |
| Acceptance testing/əkˈseptəns ˈtestɪŋ/ | Testing by the customer against requirements to decide whether a product is suitable. |
| test strategy/test ˈstrætədʒi/ | テスト戦略 |
| test plan/test plæn/ | テストプラン |
| expected output/ekˈspektɪd ˈaʊtpʊt/ | The result a test should produce if the program works correctly. |
| actual output | The result a program produces when a test is run. |
| expected result | |
| Normal data/ˈnɔːml ˈdeɪtə/ | Typical valid values inside the range, which should be accepted and processed correctly. |
| Abnormal data/əbˈnɔːml ˈdeɪtə/ | Values that should be rejected, out of range or the wrong type. |
| Extreme data/ekˈstriːm ˈdeɪtə/ | The smallest and largest values that a program should accept. |
| Boundary data/ˈbaʊndəri ˈdeɪtə/ | Values at and just outside the edges of the accepted range. |
| Corrective maintenance/kəˈrektɪv ˈmeɪntənəns/ | The process of fixing faults found in software after release. |
| Adaptive maintenance/əˈdæptɪv ˈmeɪntənəns/ | The process of changing software to keep it working in a changed environment. |
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ | System software that manages hardware resources and provides services for applications. |
| API/ˌeɪ piː ˈaɪ/ | A set of rules that allows one program to use another program's services. |
| Perfective maintenance/pəˈfektɪv ˈmeɪntənəns/ | The process of improving software that already works after its release. |
| algorithm/ˈælɡərɪθəm/ | A finite sequence of precise steps for solving a problem or carrying out a task. |
| data flow | The movement of data through the different parts of a program. |
| subroutine/ˈsʌbruːtiːn/ | A named set of instructions that performs a task when called. |
| caller/ˈkɔːlə/ | The program or module that asks another module to run. |
| parameter list | The ordered list of variables that receive values when a subroutine is called. |
| data structure/ˈdeɪtə ˈstrʌktʃə/ | A way of organising and storing data to support particular operations. |
| regression testing/rɪˈɡreʃn ˈtestɪŋ/ | 回帰テスト |
37秒
- On 4 June 1996 the first Ariane 5 rocket lifted off from French Guiana. Thirty-seven seconds later it veered off course and destroyed itself. The payload was four satellites worth $370 million.
- 原因は、アリアン4から再利用された1行のコードであった。このコードは64ビット数を16ビット整数に変換していた。アリアン5はより速く飛んだため、数値が大きくなり、変換時にオーバーフローが発生した: 打ち上げ後に不要になるルーチンにおける実行時エラーである。
- このコードはアリアン5の飛行データでテストされたことがなかった。新しいロケットの範囲の極端な値におけるテストデータは誰も選んでいなかった。
- この教訓は、3種類のエラー、テスト方法、テストデータの選び方、リリース後のプログラム維持についてである。

エラーの3種類
- 構文エラーは言語の文法を破る: 括弧の漏れ、誤記されたキーワードなど。翻訳時に検出されるため、修正されるまでプログラムは実行されない。
- 実行時エラーはプログラムが実行中に発生する: 0での除算、存在しないファイル、配列インデックスの範囲外など。プログラムがクラッシュするか例外を投げる; 修正方法は危険な操作前のチェックである。
- 論理エラーはプログラムを実行させて誤った結果を出力させる:
+が-である、オフバイワンループ、条件の順序違いなど。これに警告は出ず、テストとトレースによってのみ判明する。

翻訳時に発見、実行時に発見、出力のみで発見

Match each kind of error to how it shows up.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Syntax = caught at translation; logic = wrong output; run-time = crash while running.
演習例: エラーの特定と修正
Total ← 0
FOR i ← 1 TO Count
Total ← Total + Marks[i]
NEXT i
Average ← Total / Count
IF Average > 50 THEN
OUTPUT "Pass"
- 構文:
IFにENDIFがない。翻訳器は拒否する。実行時:Countが0の場合、除算は失敗する;IF Count > 0 THENでガードする。論理: パスが50以上の場合、> 50はちょうど50で学生に不合格とする;>= 50であるべきである。 - 種類を名付け、なぜその種なのかを説明し、修正を述べる。3つの部分、3点満点。
A program divides a total by the number of entries and crashes when the input file is empty. This is a:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Division by zero happens while the program runs and stops it. A guard such as IF Count > 0 fixes it.
テスト方法: コードを読む
- ドライランは、纸上でコードをトレースし、各行ごとにトレーステーブルに各変数の値を書き出すことである。
- ウォークスルーとはチームレビューのことです。プログラマーがコードを一行ずつ説明し、同僚が欠陥を探します。
- ホワイトボックステストはコードの内部構造に基づいてテストを設計し、すべてのステートメント、分岐、ループを実行させる。ブラックボックステストは仕様のみに基づいてテストを設計する: 入力を与え、出力を期待値と比較するが、コード自体は見ない。

外部から内側を見る、または内側からすべてのパスを見る

Designing test cases from the specification only (inputs and expected outputs), ignoring the code inside, is called ______-box testing.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Black-box tests from the spec; white-box uses the code's internal structure to cover statements and branches.
テスト方法: 統合とリリース
- 統合テストは個別にテストされたモジュールを組み合わせて、それらの間のインターフェースをテストする。スタブはまだ書かれていないモジュールの代わりとなり、固定値を返すことで残りの部分をトップダウンでテストできるようにする。
- アルファテスト αは、リリース前に開発者によって社内で行われる。ベータテスト βは、限られた実使用者のグループに、彼らの環境でプログラムを提供する。
- 受入テストは、顧客によって要件に基づいて行われ、製品が用途に適しているかどうかを決定する。
Software process lab
Classify development examples by the stage or tool they belong to.
演習例: どのような状況にどのようなテスト方法か
- レポートモジュールは完成しているが、それが呼ぶデータベースモジュールはまだ存在しない: 固定データ返回するスタブを使ってテストする。
- 2つのモジュールは各自のテストでは成功するが、一方の出力が他方の入力となる場合に失敗する: インターフェースの統合テスト。
- ソフトウェアは完成していますが、一般公開前に実環境での欠陥を特定したいと企業は望んでいます: 限定されたユーザーによるベータテスト。
- 顧客が支払いを行うかどうかを決定します: 合意された要件に対する受入テスト。その方法と目的をそれぞれ名指して答えてください。
Match each situation to the testing method it needs.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Stub for a missing part, beta for real users, acceptance for the customer, integration for the joins.
テスト戦略とテスト計画
- テスト戦略とは、高レベルのアプローチです: どの種類のテストを行うか、誰が行うか、いつ行うか、次のフェーズに進むために何が必要かを定義します。
- テスト計画とは、詳細なテストのリストです。各テストについて、目的、入力データ、期待される出力、そしてテスト実行時の実際の出力を記録する列が含まれます。
- 期待される結果がないテストはテストではありません。それは単にプログラムが何をしたかを示すだけで、それが正しいかどうかを示すものではありません。
A test plan lists, for each test, the input data and the expected output.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Purpose, input, expected output and a column for the actual output. The strategy is the high-level approach; the plan is the detailed list.
テストデータの選択
- 通常データ: 範囲内の典型的で有効な値であり、正常に受け入れられ処理されるべきものです。
- 異常データ: 受け入れられてはいけない値で、範囲外または型が不適切なものです。
- 極端データ: 範囲の端にある、まだ受け入れられる最大および最小の値です。境界データ: 各端またぎのペアで、受け入れられる極端値と、それよりわずかに外側で拒絶される値の組み合わせです。ここでオフ・バイ・ワンエラーが隠れています。

内部、外部、および線上

For a field that accepts marks 0–100, which are the boundary test values?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Boundary data sits at the edges of the valid range (and just outside) — where off-by-one errors hide.
演習例: 0から100までの得点用テストデータ
| 種類 | データ | 期待される結果 |
|---|---|---|
| 通常 | 50, 75 |
受理され処理される |
| 異常 | -10, 200, "abc" |
拒絶される: 範囲外または型が間違っている |
| 極端 | 0, 100 |
受理される: 最小および最大の有効値 |
| 境界 | -1 と 0、100 と 101 |
-1 拒否、0 受理;100 受理、101 拒否 |
- 各行には期待される結果が必要です。入力だけなら表でも半分しか得点できません。極端値は受理されます:
-1は境界値であり、極端値ではありません。

A field accepts marks from 0 to 100. Which values are extreme test data? Select すべて that apply.
難易度 2/5 · 140 コイン + 今日初回達成時の小ボーナス
Extreme values are the smallest and largest still accepted. -1 is rejected, so it is boundary or abnormal; 50 is normal.
メンテナンス
- プログラムの生涯コストの大部分はリリース後に消費されます。修正メンテナンスは使用中に発見された欠陥を修正します。
- 適応メンテナンスは、変化する環境下でプログラムを動作させ続けます: 新しいオペレーティングシステム、新しいAPI、法律の変更など。
- 改善メンテナンスは既に動作しているプログラムを向上させます: 高速化、ユーザーからの要望に基づく新機能追加など。プログラムの生涯を通じてこれら3つすべてが必要な場合があります。

修理し、動作させ続け、良くする

Corrective maintenance fixes faults, perfective maintenance improves features, and adaptive maintenance keeps the software working in a changed environment.
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Three maintenance types: corrective (fix bugs), perfective (enhance), adaptive (new OS/hardware/rules).
A payroll program is changed because the tax law changed. Which kind of maintenance is this?
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
The program was not faulty and is not being improved; its environment changed. That is adaptive maintenance.
既存プログラムの改修
- 既存コードを読み解き、アルゴリズムとデータフローを理解してください。変更が必要な場所を見つける: どのサブルーチン、どの行に該当するか。
- 変更を最小限に留め、正しく動作しているコードを再記述しないでください。関連するすべての部分を更新します: 変更されたパラメータリストを持つ呼び出し元、変更されたデータ構造を使用する各ルーチンなど。
- 新的挙動と旧来の挙動の両方をテストします: 回帰テストは、以前正常だったものが壊れていないか確認します。その後、変更点を文書化します。
After changing a program, regression testing checks that:
難易度 1/5 · 100 コイン + 今日初回達成時の小ボーナス
Regression testing re-runs old tests to confirm existing behaviour still works after a change.
Put the steps of amending an existing program in order.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Understand, locate, change small, propagate, test everything, record. Skipping the regression test is how a fix breaks something else.
このカードは修正されたため、翻訳が更新されるまで英語で表示されます。
Marks that slip away
- Extreme is accepted; abnormal is rejected.
0and100are extreme;-1and101are boundary values on the rejected side. - A logic error can produce wrong output or lead to a run-time error, such as an out-of-range array access.
- Alpha is in-house; beta is real users outside. A stub replaces a missing module; it is not a test method for finished code.
- A test plan row without an expected output 预期输出 earns nothing. Regression testing follows every change.
理解できましたか
- 構文エラーは翻訳を停止する · 実行時エラーは動作中のプログラムをクラッシュさせる · 論理エラーは正常に動作するが間違った出力を与え、テストによってのみ検出される
- テスト手法: ドライラン, ウォークスルー, ホワイトボックス(コードから)、ブラックボックス(仕様から)、統合(インターフェース、欠落モジュールにはスタブを使用)、アルファ(社内)、ベータ(実際のユーザー)、受入(顧客)
- テストデータ: 通常は受理、異常は拒絶、極端は受理される端、境界は各端の両側; 各テストには期待される結果がある
- メンテナンス: 修正で欠陥を直す、適応で環境に対応させる、改善で向上させる; 小規模に改修し、呼び出し元を更新し、回帰テストを実施する
何が問題でしたか?この内容はサイトの運営チームだけが確認します。