This page looks best with JavaScript enabled

PIE Model

 ·  ☕ 2 min read

Fault, Error & Failure

  • 在軟體與硬體中都有Fault, Error & Failure,此處我們只討論軟體

Software Fault

  • A static defect in the software(i.e., defect)
  • 靜態存在於code中的錯誤

Software Error

  • An incorrect internal state that is the manifestation of some faults
  • 由fault觸發的錯誤中間狀態

Software Failure

  • External, incorrect behavior with respect to the requirements of othere description of the expected behavior
  • 由Error所傳播出去,使測試人員或使用者所觀測到的失效行為

實例

test_sample

  • 說明 - 給定input numbers, 算出平均值
  • Fault - i的初始值誤設為1(應為0)
  • Error - sum誤算為4+5 (應為3+4+5)
  • Failure - mean誤算為3 (應為3)

PIE Model

  • 首字母P、I、E所組成
  • 只有達成下面三項,才會得到failure

Execution/Reachability -> Fault

  • The location or lcations in the program that contain the fault must be reached
  • 測試必須執行到fault的位置

Infection -> Error

  • The state of the program must be incorrect
  • 即使執行到fault的位置,也不一定會觸發Error
  • test_sample
  • 此例中,即使執行到了fault,但碰巧地沒有觸發error,最終的結果也是正確

Propagation -> Failure

  • The infected state must propagate to cause some output of the program to be incorrect
  • 即使執行到了fault,觸發了error,也可能沒有failure
  • test_sample
  • Fault - length長度錯誤值 number.length-1 (應為number.length)
  • Error - sum值計算錯誤3+5(應為3+5+4)
  • Failure - 然後最終碰巧地沒有Failure

Quiz

  • Is there is a fault, which cannot be revealed by any test?
  • Is it a fault or not a fault?
  • 我的見解是,這不算fault,因為唯有被測試出來,才能稱之為fault,雞生蛋、蛋生雞的概念

Exercise

  • Please constrct a simple program P(with a fault) and 3 tests(t1, t2, t3), s.t.
    • t1 executes the fault, but no error
    • t2 (executes the fault and) produces an error, but no failure
    • t3 produces a failure
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
string string_reverse(string input){
    int length = input.length() - 2;
    int i = 1;
    int j = length;
    while(i < j) {
        swap(input[i], input[j]);
        i++;
        j--;
    }
    return input;
}
  • tests(t1, t2, t3)
    1. t1 =
    2. t2 =
    3. t3 =
Share on

Bill Zhong
WRITTEN BY
Bill Zhong
Software Engineer