码迷,mamicode.com
首页 > Web开发 > 详细

.NET测试断言工具Shouldly

时间:2017-07-14 18:05:22      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:condition   类型   equal   git   size   元素   对象   https   tags   

.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

.NET测试断言工具Shouldly

标签:condition   类型   equal   git   size   元素   对象   https   tags   

原文地址:http://www.cnblogs.com/mmry/p/7171696.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!