zoukankan      html  css  js  c++  java
  • pythonunittest(9)

    测试边界条件

    Testing the edges
    When we write automated tests, we pick the inputs and assert the expected outputs. It is
    important to test the limits of the inputs to make sure our code can handle good and bad
    inputs. This is also known as testing corner cases.

    1. Create a new file named recipe9.py in which to put all our code for this recipe.

    2. Pick a class to test. In this recipe, we'll use another variation of our Roman numeral
    converter. This one doesn't process values greater than 4000.

    3. Create a test case that sets up an instance of the Roman numeral converter.

    4. Add several test methods that exercise the edges of converting to Roman numeral
    notation.

    5. Add several test methods that exercise the edges of converting to decimal notation.

    6. Add some tests that exercise the tiers of converting decimals to Roman numerals.

    7. Add some tests that input unexpected values to the Roman numeral converter.

    8. Add a unit test runner.

    测试代码:

    Code

    结果输出:

    .................
    ----------------------------------------------------------------------
    Ran 17 tests in 0.000s

    OK

    注意类似这样的代码:

    Code

    用于捕获程序中的异常

  • 相关阅读:
    asp.net zero 8.2 学习-9-多租户设置,发送邮件配置
    asp.net zero 8.2 学习-8-实现在页面添加、编辑、删除、查看实体
    asp.net zero 8.2 学习-7-展示实体列表,实现查询,分页,过滤,排序功能
    asp.net zero 8.2 学习-6-权限控制
    asp.net zero 8.2 学习-5-实现增删改查服务及API测试
    asp.net zero 8.2 学习-4-创建接口及服务
    asp.net zero 8.2 学习-3-添加实体,并迁移到数据库
    asp.net zero 8.2 学习-2-创建一个页面
    asp.net zero 8.2 学习-1-安装
    .net core 3.1 jwt认证
  • 原文地址:https://www.cnblogs.com/luhouxiang/p/2560407.html
Copyright © 2011-2022 走看看