软件测试实战(三)重构-冒烟测试

产品需求 明确部分

支持4位以内正整数加减乘除
一次计算只支持一个运算符号
错误场景一律定义 错误输入

UED出图


开发设计变更

输入逻辑判断
接口定义变更 one=1&cal=+&two=1
页面charset设置utf8

前端代码变更

<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
</head>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"><body><form id="form-cal" method="get" action="http://localhost:8080/cal">    计算输入:    <input type="text" name="one" value="" id="one">    <input type="text" name="cal" value="" id="cal">    <input type="text" name="two" value="" id="two">    <span class="btn btn-default btn-sm" id="btn-jq-form">计算</span></form><script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script><script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script><script src="https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js"></script><script>    // jquery.form 方式    $('#btn-jq-form').click(function () {        $('#form-cal').ajaxSubmit({            dataType: 'text',            success: function (resp) {                console.info('返回的数据', resp);                $('#resp').html(resp);            }        });    });</script><p id="resp">结果</p></body></html>

服务端代码变更

# -*- coding: utf-8 -*-
import web
urls = (  '/', 'index',  '/cal','cal',)
class index:
     def GET(self):
         return web.seeother('/static/sample.html')
 class cal:
     def GET(self):
         try:
             cal = web.input()['cal'].strip()
             one = web.input()['one'].strip()
             two = web.input()['two'].strip()
         except Exception as e:
             print e
             return u"错误输入"
         #check cal
         if cal not in ['+','-','*','/']:
             return u"错误输入"
         if not one.isalnum() or \
            len(one) > 8 or \
            not two.isalnum() or \
            len(two) > 8 :
             return u"错误输入"
         if cal == '/' and two == '0':
             return u"错误输入"
         run = one + cal + two
         return "%s %s %s = %s" % (one,cal,two,eval(run))
 if __name__ == "__main__":
     app = web.application(urls, globals())
     app.run()

执行一轮冒烟测试,没有发现问题

1+2

1 0 1

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,064评论 19 139
  • 写作第一天,从哪里开始,从哪里提笔?我不知道,太长时间没有动过笔,哪怕是日记,现在要开始写点东西,真是无从下手。上...
    大金_K阅读 2,350评论 0 0
  • 学心理学专业的学生,大部分都遇到过这四种情况: (1) “嘿,你大学学什么专业的?” “心理学。” “哇!那你知道...
    南星南阅读 7,530评论 41 63
  • 我最软弱的地方,是舍不得。舍不得一段不再精采的感情,舍不得一份虚荣,舍不得掌声。舍 我一直以为最好...
    冷小洋阅读 1,400评论 0 0
  • “做最好的自己!”其实我不知道什么是最好的自己~ 中国有十几亿人口,世界上又有千千万,成功的人,被人...
    建筑系丫头阅读 1,423评论 0 1

友情链接更多精彩内容