• 2016 Tianjin University Software Testing (homework2)


    Question one:Identify the fault.
    the answer:
    the first function :The for-loop misses the 0 index,so that should be -- for(int i=x.length-1;i>=0;i--)
    the second function: The for-loop is from beginning to the end ,but we want to find the last 0. So that should be -- for(int i=x.length-1;i>=0;i--)

    Question two:If possible, identify a test case that does not execute the fault. (Reachability)
    The answer:
    the first function:x==null will throw a NullPointerException and it doesn't enter the for-loop test ,so there is no fault to execute. Just like this: Input: x=null;y=0 Expected:NullPointerException The real output: NullPointerException
    the second function:there is not such a case.

    Question three:If possible, identify a test case that executes the fault, but does not result in an error state.
    The answer:
    the first function: the y doesn't appear in the first position,there is no error. Just like this: Input: x=[0,2,0];y= 2; Expected:1 The real output: 1
    the second function: if the for-loop just executes once, that should be ok. Because the first become the last. Just like this: Input: x=[0] Expected:1 The real output: 1

    Question four:If possible identify a test case that results in an error, but not a failure.
    The answer:
    the first function: the y doesn't appear in the x array. Just like this: Input: x=[0,2,0];y= 3; Expected:-1 The real output: -1
    the second function: if the for-loop just executes more than once and the 0 appears only once, that should be ok. Just like this: Input: x=[1,0,2] Expected:1 The real output: 1

  • 相关阅读:
    JS防抖和节流
    移动端屏幕适配
    vue、react对比
    HTTP缓存
    程序员必备技术网站
    W3C标准、表现与数据分离、web语义化
    VUE的响应式原理
    react更新渲染及渲染原理
    ubuntu下mysql的环境搭建及使用
    apktool反编译工具
  • 原文地址:https://www.cnblogs.com/ida-xj/p/5264811.html
Copyright © 2020-2023  润新知