可视性代码层面描述

可测试性战术

可测试性战术的目标是允许在完成软件开发的一个增量后,轻松地对软件进行测试。

测试的目标是发现错误:

可测试性战术分类图:

ajax请求测试:

$.ajax({
            type :"POST",
            url : context+"/countServlet?method=listword",
            dataType :"json",           
            async : false,
            global :false,
            success : function(json) {
                content="";
                for(var j=0;j<json[0].length;j++){
                    content+="<div class='layui-colla-item'><h2 class='layui-colla-title'>"+json[0][j].name+"</h2>";
                    content+="<div class='layui-colla-content'><div class='layui-collapse' lay-accordion=''>";
                    for(var i=0;i<json[1].length;i++){
                        content+="<div class='layui-colla-item'><h2 class='layui-colla-title'>"+json[j+1][i].name+"</h2>";
                        content+="<div class='layui-colla-content'><p>"+json[j+1][i].wordexplain+"</p></div></div>";
                    }
                    content+="</div></div></div>";
                }
                $(".jieshi").html(content);
            },
            error: function(message){
                alert("请求失败");
            }
        });

当ajax请求失败,ajax提示错误信息。

try catch测试:

try {
    words = dao.listwords(types.get(i).getName());
    total.add(JSONArray.fromObject(words));
} catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

当数据请求失败,抛出异常。

 

猜你喜欢

转载自www.cnblogs.com/yuanxiaochou/p/12400600.html