gpt4 book ai didi

assertj - 信任断言库与AssertJ的比较

转载 作者:行者123 更新时间:2023-12-04 03:57:24 26 4
gpt4 key购买 nike

在停止开发后,我使用了FEST-Assert并移至AssertJ

最近,我被指向 Google 存储库以及另一个声明库Truth(http://google.github.io/truth/)。

阅读示例,我发现开始使用它比AssertJ更有优势。因此,使用什么只是口味问题。但是,也许我错过了要点,对吗?

最佳答案

从他们在GitHub上的comments之一:

The core difference is that the design of Truth includes two specific areas of extensibility - that of a strategy for proposition failure - such that a "subject" for Integers, or a subject for Strings can be re-used in the context of completely different results for failure. A notable example is the distinction between JUnit's use of AssertionError and it's AssumptionViolationException. Truth lets you use the same proposition classes for both.

The other area of flexibility is the ability to create new assertion/proposition types and hook them in without declaring possibly conflicting static methods to import. This can be for new types (say, adding protobufs) or for new uses of existing types (say, Strings that are treated as Uris). This is the assertAbout() feature.

Other than that, Truth is very similar to AssertJ, since it was inspired by FEST, of which AssertJ is a fork of the 2.0 development line.



综上所述,Truth设计为更具扩展性和灵活性,但是AssertJ对于标准类型的断言将非常有用(可能最大)。

关于assertj - 信任断言库与AssertJ的比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32754965/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com