首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

测试工具中的设计模式实例谈---装饰模式

理想的装饰器模式要求对客户端透明,只改变行为,不改变接口。 ##Hamcrest中的装饰模式 在Hamcrest中,为了表达更为复杂的Matcher逻辑,或者增强可读性,框架提供了类似Is\IsNot\Allof\AnyOf等装饰器, 实现了对于原有被装饰对象的功能增强,属于一种简化的装饰模式。 IsNot: NOT AllOf:AND AnyOf: OR ``` assertThat(cheese, is(equalTo(smelly))) assertThat(cheese, is(not(equalTo(smelly)))) assertThat("myValue", allOf(startsWith("my"), containsString("Val"))) assertThat("myValue", anyOf(startsWith("foo"), containsString("Val"))) ``` Matcher是hamcrest框架的核心,其的主要功能是传入一个类实例,以判断该实例是否能和当前Matcher所定义的逻辑匹配。BaseMatcher实现了接口Matcher,而其下的Matcher,如IsAnything、IsEqual、IsSame、IsNull等都是ConcreteComponent。右侧的Matcher,如Is、IsNot、AnyOf、AllOf)都是Decorator。

03
您找到你想要的搜索结果了吗?
是的
没有找到

Install Jumpserver6

perl-File-Path noarch 2.09-2.el7 base 26 k perl-File-Temp noarch 0.23.01-3.el7 base 56 k perl-Filter x86_64 1.49-3.el7 base 76 k perl-Getopt-Long noarch 2.40-3.el7 base 56 k perl-Git noarch 1.8.3.1-14.el7_5 updates 54 k perl-HTTP-Tiny noarch 0.033-3.el7 base 38 k perl-PathTools x86_64 3.40-5.el7 base 82 k perl-Pod-Escapes noarch 1:1.04-292.el7 base 51 k perl-Pod-Perldoc noarch 3.20-4.el7 base 87 k perl-Pod-Simple noarch 1:3.28-4.el7 base 216 k perl-Pod-Usage noarch 1.63-3.el7 base 27 k perl-Scalar-List-Utils x86_64 1.27-248.el7 base 36 k perl-Socket x86_64 2.010-4.el7 base 49 k perl-Storable x86_64 2.45-3.el7 base 77 k perl-TermReadKey x86_64 2.30-20.el7 base 31 k perl-Test-Harness noarch 3.28-3.el7 base 302 k perl-Text-ParseWords noarch 3.29-4.el7 base 14 k perl-Thread-Queue noarch 3.02-2.el7 base 17 k perl-Time-HiRes x86_64 4:1.9725-3.el7 base 45 k perl-Time-Local noarch 1.2300-2.el7 base 24 k perl-constant noarch 1.27-2.el7 base 19 k perl-libs x86_64 4:5.16.3-292.el7 base 688 k perl-macros x86_64 4:5.16.3-292.el7 base 43 k perl-parent noarch 1:0.225-244.el7 base 12 k perl-podlators noarch 2.5.1-3.el7 base 112 k perl-threads x86_64 1.87-4.el7

02

扫码

添加站长 进交流群

领取专属 10元无门槛券

手把手带您无忧上云

扫码加入开发者社群

相关资讯

热门标签

活动推荐

    运营活动

    活动名称
    广告关闭
    领券