From 21ec975911c25264144d7053a074eb472f8e64db Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Mon, 6 Jun 2022 11:55:09 -0400 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=AD=E8=A8=80=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80=EF=BC=88Assertion=EF=BC=89=20=E7=9A=84?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- testing-modules/assertion-libraries/README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/testing-modules/assertion-libraries/README.md b/testing-modules/assertion-libraries/README.md index 5be5c7e004..5483bcf194 100644 --- a/testing-modules/assertion-libraries/README.md +++ b/testing-modules/assertion-libraries/README.md @@ -1,5 +1,15 @@ +## 测试断言(Assert) +断言(Assertion)是一种调试程序的方式,很多开发语言中都支持这种机制。 -## Relevant Articles +在实现中,assertion 就是在程序中的一条语句,它对一个 boolean 表达式进行检查,一个正确程序必须保证这个 boolean表达式的值为true;如果该值为 false,说明程序已经处于不正确的状态下,assert 将给出警告或退出。 + +在 Java中,使用 assert 关键字来实现断言。 语句 assert x >= 0; 即为断言,断言条件 x >= 0 预期为 true 。 + +如果计算结果为 false ,则断言失败,抛出 AssertionError。 + +assertion(断言) 在软件开发中是一种常用的调试方式,很多开发语言中都支持这种机制。 + +### 相关文章 - [AssertJ’s Java 8 Features](http://www.baeldung.com/assertJ-java-8-features) - [AssertJ for Guava](http://www.baeldung.com/assertJ-for-guava)