java-tutorials/testing-modules/assertion-libraries/README.md

21 lines
1.3 KiB
Markdown
Raw Normal View History

## 测试断言Assert
断言Assertion是一种调试程序的方式很多开发语言中都支持这种机制。
2022-06-06 11:45:16 -04:00
在实现中assertion 就是在程序中的一条语句,它对一个 boolean 表达式进行检查,一个正确程序必须保证这个 boolean表达式的值为true如果该值为 false说明程序已经处于不正确的状态下assert 将给出警告或退出。
在 Java中使用 assert 关键字来实现断言。 语句 assert x >= 0; 即为断言,断言条件 x >= 0 预期为 true 。
如果计算结果为 false ,则断言失败,抛出 AssertionError。
### 相关文章
2022-06-06 11:45:16 -04:00
- [AssertJs Java 8 Features](http://www.baeldung.com/assertJ-java-8-features)
- [AssertJ for Guava](http://www.baeldung.com/assertJ-for-guava)
- [Introduction to AssertJ](http://www.baeldung.com/introduction-to-assertj)
- [Testing with Google Truth](http://www.baeldung.com/google-truth)
- [Testing with JGoTesting](http://www.baeldung.com/jgotesting)
- [Guide to JSpec](http://www.baeldung.com/jspec)
- [Custom Assertions with AssertJ](http://www.baeldung.com/assertj-custom-assertion)
- [Using Conditions with AssertJ Assertions](http://www.baeldung.com/assertj-conditions)
- [AssertJ 的异常Exception )断言](https://www.ossez.com/t/assertj-exception/13988)