zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    今年要读的书
    java多线程
    json-lib 使用教程
    tomcat原理
    静态long类型常量serialVersionUID的作用
    使用junit4测试Spring
    MySQL各版本的区别
    spring mvc 下载安装
    hibernate、struts、spring mvc的作用
    【面试】hibernate n+1问题
  • 原文地址:https://www.cnblogs.com/ida-xj/p/5264811.html
Copyright © 2011-2022 走看看