zoukankan      html  css  js  c++  java
  • .NET测试断言工具Shouldly

    .NET测试断言工具Shouldly

    Shouldly在GitHub的开源地址:https://github.com/shouldly/shouldly
    Shouldly的官方文档:http://docs.shouldly-lib.net/
    Shouldly断言框架提供了相等、迭代、动态变量、字符串、字典、任务/异步,以及异常等多方面的支持。

    Equality 相等

    其中之一

    ShouldBeOneOf
    ShouldNotBeOneOf

    大于

    ShouldBeGreaterThan

    小于

    ShouldBeLessThan

    类型

    ShouldBeOfType

    可以类型转换

    ShouldBeAssignableTo

    在一个范围里面

    ShouldBeInRange
    ShouldNotBeInRange

    枚举

    集合以某个对象开头

    ShouldStartWith

    集合中所有的元素满足条件

    ShouldAllBe

    集合中包含某个对象

    ShouldContain
    ShouldNotContain

    集合中包含满足条件得元素

    ShouldContain(Predicate)
    ShouldNotContain(Predicate)

    为集合为空集合

    ShouldBeEmpty
    ShouldNotBeEmpty

    是集合中的其中之一

    ShouldBeOneOf

    是集合对象的子集

    ShouldBeSubsetOf

    字符串

    包含关键词

    ShouldContainKey

    字符串开头和结尾

    ShouldStartWith
    ShouldNotStartWith
    ShouldEndWith
    ShouldNotEndWith

    字符串包含

    ShouldContain
    ShouldNotContain
    (包含空格)
    ShouldContainWithoutWhitespace

    匹配正则表达式

    ShouldMatch

    为空字符串或者null

    ShouldBeNullOrEmpty
    ShouldNotBeNullOrEmpty

    字典

    包含key

    ShouldNotContainKey

    包含key和value

    ShouldContainKeyAndValue
    ShouldNotContainValueForKey

    异常

    抛出异常

    ShouldThrow
    ShouldNotThrow
    ShouldNotThrow(Func<Task>)

    异步和同步

    抛出异常

    ShouldThrow

    拥有属性

    ShouldHaveProperty

    完成

    CompleteIn

    动态

    满足所有条件

    参数为所有断言,会检测其中所有断言,并且给出提示
    ShouldSatisfyAllConditions

  • 相关阅读:
    Beta 冲刺 (2/7)
    Beta 冲刺 (1/7)
    2017软件工程实践总结
    华为软件开发云评测
    android开发——用户头像
    学生&部门智能匹配程序
    学生会里学生汇
    数独棋盘生成器
    读与思
    Java接口
  • 原文地址:https://www.cnblogs.com/mmry/p/7171696.html
Copyright © 2011-2022 走看看