GitHub - joel-costigliola/assertj-core: AssertJ is a library providing easy to u...
source link: https://github.com/joel-costigliola/assertj-core
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
AssertJ - Fluent assertions for java
AssertJ provides a rich and intuitive set of strongly-typed assertions to use for unit testing (with JUnit, TestNG or any other test framework).
- AssertJ's goals
- Quick start
- Latest News
- Features highlight
- Assertions for custom types
- Replacing JUnit assertions with AssertJ Assertions
- Migrating from FEST Assertions
- Contributing
The AssertJ web site contains all projects documentation and can be found here. It notably includes the AssertJ Core documentation.
You can ask questions in stackoverflow (assertj tag) and make suggestions by simply creating an issue.
AssertJ's goals
AssertJ is composed of several modules:
A core module (this one) to provide assertions for JDK types (String
, Iterable
, Stream
, Path
, File
, Map
...) - see AssertJ Core documentation and javadoc.
A Guava module to provide assertions for Guava types (Multimap
, Optional
...) - see AssertJ Guava documentation and javadoc.
A Joda Time module to provide assertions for Joda Time types (DateTime
, LocalDateTime
) - see AssertJ Joda Time documentation and javadoc.
A Neo4J module to provide assertions for Neo4J types (Path
, Node
, Relationship
...) - see AssertJ Neo4J documentation and javadoc.
A DB module to provide assertions for relational database types (Table
, Row
, Column
...) - see AssertJ DB documentation and javadoc.
A Swing module provides a simple and intuitive API for functional testing of Swing user interfaces - see AssertJ Swing documentation and javadoc.
Assertion missing? Please create an issue!
AssertJ's assertions are super easy to use: just type assertThat
followed by the actual value in parentheses and a dot,
then any Java IDE will show you all assertions available for the type of the object. No more confusion about the
order of "expected" and "actual" value.
AssertJ's assertions are very close to plain English.
A lot of effort has been spent to provide intuitive failure messages showing clearly why the assertion failed.
Note that AssertJ 3.x requires at least Java 8 and AssertJ 2.x requires at least Java 7.
Quickstart
It is easy to start using AssertJ, just follow the one minute starting guide.
Latest News
To read details on the latest releases, please go to AssertJ Core latest news.
Assertions for custom types
Having assertions for common types like List
is great, but you might want some assertions specific to your own types. It is simple to write assertions for your custom types with AssertJ because it is easily extensible.
Moreover, to ease your work, we provide assertions generator that can take a set of custom types and create specific assertions. The tools provided are:
Replacing JUnit assertions with AssertJ Assertions
To help you replace JUnit assertions with AssertJ ones, you can use a script or do regexp search and replace manually as described here.
Migrating from FEST Assertions
Check our migration guide, it covers migrating from Fest 1.4 and migrating from Fest 2.x.
Want to contribute?
You are encouraged to contribute any missing, useful assertions. To do so, please read the contributing section.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK